linux 中的 php 无法访问我的 Dropbox 帐户
Can't get access to my Dropbox account from php in linux
我正在下载 dropbox-php-sdk。行
接下来,我在 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);
?>
当,我运行这个脚本,我有输出:
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
我哪里出错了?我需要获取帐户信息。但是我不明白,哪里出错了。
如异常所述,您没有安装 PHP cURL 扩展。
根据您的 linux 发行版,命令可能会有所不同,快速 google for "install php curl [distro]" 会给您答案。
如果您的发行版使用 apt-get,请使用以下命令:
sudo apt-get install php5-curl
别忘了重启apache。
您需要安装 cURL 扩展程序才能使用 Dropbox SDK...根据例外情况。
The Dropbox SDK requires the cURL PHP extension, but it looks like you don't have it
我正在下载 dropbox-php-sdk。行 接下来,我在 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);
?>
当,我运行这个脚本,我有输出:
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
我哪里出错了?我需要获取帐户信息。但是我不明白,哪里出错了。
如异常所述,您没有安装 PHP cURL 扩展。
根据您的 linux 发行版,命令可能会有所不同,快速 google for "install php curl [distro]" 会给您答案。
如果您的发行版使用 apt-get,请使用以下命令:
sudo apt-get install php5-curl
别忘了重启apache。
您需要安装 cURL 扩展程序才能使用 Dropbox SDK...根据例外情况。
The Dropbox SDK requires the cURL PHP extension, but it looks like you don't have it