This repository was archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathexample.php
More file actions
57 lines (48 loc) · 2.12 KB
/
Copy pathexample.php
File metadata and controls
57 lines (48 loc) · 2.12 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
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Example extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->helper('url');
}
// Call this method first by visiting http://SITE_URL/example/request_dropbox
public function request_dropbox()
{
$params['key'] = 'YOUR DROPBOX CONSUMER KEY';
$params['secret'] = 'YOUR DROPBOX CONSUMER SECRET';
$this->load->library('dropbox', $params);
$data = $this->dropbox->get_request_token(site_url("example/access_dropbox"));
$this->session->set_userdata('token_secret', $data['token_secret']);
redirect($data['redirect']);
}
//This method should not be called directly, it will be called after
//the user approves your application and dropbox redirects to it
public function access_dropbox()
{
$params['key'] = 'YOUR DROPBOX CONSUMER KEY';
$params['secret'] = 'YOUR DROPBOX CONSUMER SECRET';
$this->load->library('dropbox', $params);
$oauth = $this->dropbox->get_access_token($this->session->userdata('token_secret'));
$this->session->set_userdata('oauth_token', $oauth['oauth_token']);
$this->session->set_userdata('oauth_token_secret', $oauth['oauth_token_secret']);
redirect('example/test_dropbox');
}
//Once your application is approved you can proceed to load the library
//with the access token data stored in the session. If you see your account
//information printed out then you have successfully authenticated with
//dropbox and can use the library to interact with your account.
public function test_dropbox()
{
$params['key'] = 'YOUR DROPBOX CONSUMER KEY';
$params['secret'] = 'YOUR DROPBOX CONSUMER SECRET';
$params['access'] = array('oauth_token'=>urlencode($this->session->userdata('oauth_token')),
'oauth_token_secret'=>urlencode($this->session->userdata('oauth_token_secret')));
$this->load->library('dropbox', $params);
$dbobj = $this->dropbox->account();
print_r($dbobj);
}
}
/* End of file example.php */
/* Location: ./application/controllers/welcome.php */