-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
47 lines (35 loc) · 1.22 KB
/
README
File metadata and controls
47 lines (35 loc) · 1.22 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
<?php
include_once("inc.oAuth.php");
include_once("inc.DropboxSync.php");
session_start();
$oAuth = new oAuth(__consumer_key__,__consumer_secret__);
if(file_exists("access_token"))
{
parse_str(file_get_contents("access_token", $data),$accessToken);
$oAuth->setToken($accessToken['oauth_token'], $accessToken['oauth_token_secret']);
}
else
{
if(!count($_GET))
{
$data = $oAuth->fetch('https://api.dropbox.com/1/oauth/request_token', array(),'GET');
if($data)
{
parse_str($data,$requestToken);
$_SESSION['request_token_key'] = $requestToken['oauth_token'];
$_SESSION['request_token_secret'] = $requestToken['oauth_token_secret'];
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
header('Location: https://www.dropbox.com/1/oauth/authorize?oauth_token='.$requestToken['oauth_token'].'&oauth_callback='.$actual_link, TRUE, 301);
exit;
}
}
else
{
$oAuth->setToken($_SESSION['request_token_key'], $_SESSION['request_token_secret']);
$data = $oAuth->fetch('https://api.dropbox.com/1/oauth/access_token', array(),'GET');
file_put_contents("access_token", $data);
}
}
$DropboxSync = new DropboxSync($oAuth);
echo "<pre>";
$DropboxSync->synchronizuj("/remote/folder/","localfolder");