dtcmadj31951 2016-08-30 11:05
浏览 78

用于PHP的Dropbox API正在使用localhost,但不在服务器上

I'm using dropbox API for PHP, and developed a small app to upload and download files from the dropbox.

This is working fine on my local machine (using WAMP), but not working if I upload it on a server.

Here is an error:

Fatal error: Uncaught exception 'Dropbox\Exception_NetworkIO' with message 'Error executing HTTP request: ' in /dropbox-sdk/lib/Dropbox/Curl.php:73

Here are my cURL settings on the server:

cURL support: enabled
cURL Information: 7.46.0
Age: 3
Features
AsynchDNS: No
Debug: No
GSS-Negotiate: No
IDN: Yes
IPv6: Yes
Largefile: Yes
NTLM: Yes
SPNEGO: No
SSL: Yes
SSPI: No
krb4: No
libz: Yes
CharConv: No
Protocols: dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host: x86_64-pc-linux-gnu
SSL Version: OpenSSL/1.0.2e
ZLib Version: 1.2.3.4
libSSH Version: libssh2/1.2.6

How can I resolve this?

Edit: Following is my code:

<?php
// Include the Dropbox SDK libraries
require_once "dropbox-sdk/lib/Dropbox/autoload.php";
use \Dropbox as dbx;

// Get access token from dropbox
$appInfo = dbx\AppInfo::loadFromJsonFile("dropbox-sdk/config.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");

$authorizeUrl = $webAuth->start();

echo "1. Go to: " . $authorizeUrl . PHP_EOL;
echo "2. Click \"Allow\" (you might have to log in first)." . PHP_EOL;
echo "3. Copy the authorization code." . PHP_EOL;
$authCode = \trim(eadline("Enter the authorization code here: "));

list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
print "Access Token: " . $accessToken . PHP_EOL;

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

// Get account info of the user
$accountInfo = $dbxClient->getAccountInfo();
print_r($accountInfo);
?>

Edit: Here is the Stack Trace:

Fatal error: Uncaught exception 'Dropbox\Exception_NetworkIO' with message 'Error executing HTTP request: ' in /dropbox-sdk/lib/Dropbox/Curl.php:73
Stack trace:
#0 /dropbox-sdk/lib/Dropbox/RequestUtil.php(200): Dropbox\Curl->exec()
#1 /dropbox-sdk/lib/Dropbox/WebAuthBase.php(41): Dropbox\RequestUtil::doPostWithSpecificAuth('PHP-Example/1.0', 'Basic d25qZDV0c...', NULL, 'api.dropbox.com', '1/oauth2/token', Array)
#2 /dropbox-sdk/lib/Dropbox/WebAuthNoRedirect.php(80): Dropbox\WebAuthBase->_finish('nNHnBxvAE8qAAAA...', NULL)
#3 /getAccessTokenForDropbox.php(21): Dropbox\WebAuthNoRedirect->finish('nNHnBxvAE8qAAAA...')
#4 {main} thrown in /dropbox-sdk/lib/Dropbox/Curl.php on line 73
  • 写回答

1条回答 默认 最新

  • doucheng9304 2016-09-13 10:31
    关注


    The issue was with the curl request being sent by the dropbox API. As dropbox sends curl requests to the IP decided at runtime (for eg. 108.160.173.164), the requests were getting blocked by my server.
    White-listing all the connections to 108.160.xxx.xxx helped to resolve this error.

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题