Piduna Valeriu Piduna Valeriu - 20 days ago 7x
Linux Question

Can't get access to my Dropbox account from php in linux

I was download dropbox-php-sdk. Ok
Next, I write script on php:

require_once "dropbox-sdk-php-1.1.6/lib/Dropbox/autoload.php";

use \Dropbox as dbx;

$dropbox_config = array(
'key' => 'fasgsasgas',
'secret' => 'gasawggasg'

$appInfo = dbx\AppInfo::loadFromJson($dropbox_config);
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");

$authorizeUrl = $webAuth->start();
echo "1. Go to: " . $authorizeUrl . "<br>";
echo "2. Click \"Allow\" (you might have to log in first).<br>";
echo "3. Copy the authorization code and insert it into $authCode.<br>";

$authCode = trim('eadasfafasfasfasfffffasfasfsafsafsafsafsafafa');

list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
echo "Access Token: " . $accessToken . "<br>";

$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");

$accountInfo = $dbxClient->getAccountInfo();

When, I run this script, I have output:

root@iredmail:/var/www/ php test2.php
PHP Fatal error: Uncaught exception 'Exception' with message 'The Dropbox SDK requires the cURL PHP extension, but it looks like you don't have it (couldn't find function "curl_init"). Library: "/var/www/".' in /var/www/
Stack trace:
#0 /var/www/ require_once()
#1 [internal function]: Dropbox\autoload('Dropbox\Request...')
#2 /var/www/ spl_autoload_call('Dropbox\Request...')
#3 /var/www/ Dropbox\WebAuthBase->_getAuthorizeUrl(NULL, NULL)
#4 /var/www/ Dropbox\WebAuthNoRedirect->start()
#5 {main}
thrown in /var/www/ on line 5

Where, I have error? I need to get account information. But I can't understand, where I have error.


As the exception says, you do not have the PHP cURL extension installed.

Depending on your linux distro, the command may be different, a quick google for "install php curl [distro]" will get you an answer.

If your distro uses apt-get use the following:

sudo apt-get install php5-curl

Don't forget to restart apache.