-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhubic_drive.php
More file actions
65 lines (48 loc) · 1.68 KB
/
hubic_drive.php
File metadata and controls
65 lines (48 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include_once "hubic_classdef.php";
//include_once "Log.php";
session_start();
$hubic_helper= new HubicDrive();
$hubic_helper->execute();
/*
define('_REDIRECT_URI_','https://' . $_SERVER['HTTP_HOST'] . '/books/hubic_drive.php');
define('CLIENT_ID',"api_hubic_add0mLihwfGhhE1RAuFNa6S3lqK5TaxT");
define('CLIENT_SECRET',"fj9T4CKKPcR6KOz9UKy0N48lhUQGj7RUOx327fKbb9nzziXEqWZgE4MQ6C6TWVeZ");
define('AUTH_URL','https://api.hubic.com/oauth/auth/');
define('TOKEN_URL', "https://api.hubic.com/oauth/token");
if(isset($_GET['code']))
{
$code = $_GET['code'];
\Logs\logInfo('code provided=' . $code);
//$hubic_helper->onCode($code);
$body='code=' . $code . '&' .
'redirect_uri=' . urlencode(_REDIRECT_URI_) . '&' .
'grant_type=authorization_code' . '&' .
'client_id=' . CLIENT_ID . '&' .
'client_secret=' . CLIENT_SECRET;
\Logs\logInfo('body for authorization token={' . $body . '}');
$post_options=array(
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_AUTOREFERER => true,
// SSL options.
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_URL => TOKEN_URL,
CURLOPT_HTTPHEADER => array( 'Authorization: Basic ' . base64_encode( CLIENT_ID . '.' . CLIENT_SECRET) )
);
$curl = curl_init();
curl_setopt_array($curl, $post_options);
$result = curl_exec($curl);
curl_close($curl);
echo $result;
}
else
{
$url = $hubic_helper->getRedirectUrl();
\Logs\logInfo('redirect to ' . $url);
header('Location: ' . $url);
}
*/
?>