Created
December 19, 2013 23:24
-
-
Save alexstone/8047973 to your computer and use it in GitHub Desktop.
Revisions
-
alexstone revised this gist
Dec 19, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ <?php /* |-------------------------------------------------------------------------- | Connect to Dropbox -
alexstone created this gist
Dec 19, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ /* |-------------------------------------------------------------------------- | Connect to Dropbox |-------------------------------------------------------------------------- */ Route::get('connect/dropbox', array('before' => 'auth', function() { $app_info = Dropbox\AppInfo::loadFromJson(Config::get('dropbox.credentials')); $webAuth = new Dropbox\WebAuthNoRedirect($app_info, "PHP-Example/1.0"); $authorizeUrl = $webAuth->start(); echo link_to($authorizeUrl, 'Authorize with Dropbox'); })); Route::get('connect/dropbox/finish', array('before' => 'auth', function() { $code = Input::get('code'); $app_info = Dropbox\AppInfo::loadFromJson(Config::get('dropbox.credentials')); $webAuth = new Dropbox\WebAuthNoRedirect($app_info, "PHP-Example/1.0"); list($accessToken, $dropboxUserId) = $webAuth->finish(Input::get('code')); // Save or update the Dropbox access record $user_dropbox = UserDropbox::where('user_id', Auth::user()->id)->first(); if(!$user_dropbox) { UserDropbox::create(array( 'user_id' => Auth::user()->id, 'dropbox_uid' => $dropboxUserId, 'access_token' => $accessToken )); } else { $user_dropbox->dropbox_uid = $dropboxUserId; $user_dropbox->access_token = $accessToken; $user_dropbox->save(); } $dbxClient = new Dropbox\Client($accessToken, "PHP-Example/1.0"); $accountInfo = $dbxClient->getAccountInfo(); print_r($accountInfo); }));