drgdn82648 2013-05-05 20:38
浏览 49

Dropbox无效访问令牌

Im following the Dropbox API here. https://www.dropbox.com/developers/core/start/php

Scrolling down the page they give you "the complete code" I copied and pasted that in my index.php

I get these instructions when visiting my index.php

1. Go to: https://www.dropbox.com/1/oauth/authorize?locale=en&oauth_token=9PURkb1SJoLJ4Z41&oauth_callback=http%3A%2F%2Flocalhost%2Fmax%2F
2. Click "Allow" (you might have to log in first)
3. Hit ENTER to continue.

I go there, click the "Allow" button and im directed back and nothing else happens.

My error console says,

PHP Notice:  Use of undefined constant STDIN - assumed 'STDIN' in /Applications/MAMP/htdocs/max/index.php on line 16
[05-May-2013 20:33:53 UTC] PHP Warning:  fgets() expects parameter 1 to be resource, string given in /Applications/MAMP/htdocs/max/index.php on line 16
[05-May-2013 20:33:54 UTC] PHP Fatal error:  Uncaught exception 'Dropbox\Exception_InvalidAccessToken' with message '
{"error": "Invalid or expired oauth_token"}' in /Applications/MAMP/htdocs/max/dropbox-sdk/Dropbox/RequestUtil.php:222
Stack trace:
#0 /Applications/MAMP/htdocs/max/dropbox-sdk/Dropbox/WebAuth.php(155): Dropbox\RequestUtil::unexpectedStatus(Object(Dropbox\HttpResponse))
#1 /Applications/MAMP/htdocs/max/index.php(19): Dropbox\WebAuth->finish(Object(Dropbox\RequestToken))
#2 {main}
  thrown in /Applications/MAMP/htdocs/max/dropbox-sdk/Dropbox/RequestUtil.php on line 222

How can i fix these errors? I just copied what they gave me

index.php

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

use \Dropbox as dbx;

$appInfo = dbx\AppInfo::loadFromJsonFile("config.json");

$dbxConfig = new dbx\Config($appInfo, "PHP-Example/1.0");

$webAuth = new dbx\WebAuth($dbxConfig);
list($requestToken, $authorizeUrl) = $webAuth->start('http://localhost/max/');

echo "1. Go to: " . $authorizeUrl . "<br>";
echo "2. Click \"Allow\" (you might have to log in first)<br>";
echo "3. Hit ENTER to continue.
";
fgets(STDIN);


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

$dbxClient = new dbx\Client($dbxConfig, $accessToken);
$accountInfo = $dbxClient->getAccountInfo();

print_r($accountInfo);

$f = fopen("working-draft.txt", "rb");
$result = $dbxClient->uploadFile("/working-draft.txt", dbx\WriteMode::add(), $f);
fclose($f);
print_r($result);

$folderMetadata = $dbxClient->getMetadataWithChildren($path);
print_r($folderMetadata);

$f = fopen("working-draft.txt", "w+b");
$fileMetadata = $dbxClient->getFile("/working-draft.txt", $f);
fclose($f);
print_r($fileMetadata);
  • 写回答

1条回答 默认 最新

  • doufeinai6081 2013-05-05 21:05
    关注

    STDIN written like that is a constant for PHP. And this constant doesn't exist by default, you must define it yourself.

    You can do it like that :

    define("STDIN", fopen('php://stdin','r'));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能