0

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

<?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();
print_r($accountInfo);
?>

When, I run this script, I have output:

root@iredmail:/var/www/test.tl# 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/test.tl/dropbox-sdk-php-1.1.6/lib/Dropbox/RequestUtil.php".' in /var/www/test.tl/dropbox-sdk-php-1.1.6/lib/Dropbox/RequestUtil.php:5
Stack trace:
#0 /var/www/test.tl/dropbox-sdk-php-1.1.6/lib/Dropbox/autoload.php(27): require_once()
#1 [internal function]: Dropbox\autoload('Dropbox\Request...')
#2 /var/www/test.tl/dropbox-sdk-php-1.1.6/lib/Dropbox/WebAuthBase.php(14): spl_autoload_call('Dropbox\Request...')
#3 /var/www/test.tl/dropbox-sdk-php-1.1.6/lib/Dropbox/WebAuthNoRedirect.php(56): Dropbox\WebAuthBase->_getAuthorizeUrl(NULL, NULL)
#4 /var/www/test.tl/test2.php(14): Dropbox\WebAuthNoRedirect->start()
#5 {main}
  thrown in /var/www/test.tl/dropbox-sdk-php-1.1.6/lib/Dropbox/RequestUtil.php on line 5

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

Greg
  • 16,359
  • 2
  • 34
  • 44

2 Answers2

0

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.

Daniel
  • 1,229
  • 14
  • 24
0

You need to have the cURL extension installed in order to use the Dropbox SDK... As per the exception.

The Dropbox SDK requires the cURL PHP extension, but it looks like you don't have it

user2924019
  • 1,983
  • 4
  • 29
  • 49