-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDropboxConnect.php
39 lines (26 loc) · 1 KB
/
DropboxConnect.php
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
<?php
namespace Hmillet\BackupCommandsBundle;
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;
use Kunnu\Dropbox\DropboxFile;
class DropboxConnect
{
private $dropbox_access_token;
function __construct($dropbox_access_token) {
$this->dropbox_access_token = $dropbox_access_token;
}
public function connect($output)
{
try {
$app = new DropboxApp("client_id", "client_secret", $this->dropbox_access_token);
$dropbox = new Dropbox($app);
$account = $dropbox->getCurrentAccount();
$output->writeln('<info>Connected to dropbox account "' . $account->getDisplayName() . '"</info>');
} catch (\Kunnu\Dropbox\Exceptions\DropboxClientException $e) {
$message = $e->getMessage();
$output->writeln('<error>Dropbox connection failed : "' . $message . '"</error>');
return false;
}
return $dropbox;
}
}