Php Twitter代码鸟错误
我正在尝试使用codebird使用PHP发送推文。起初我无法获取访问令牌,但在设置中定义CallbackURL后,这个问题似乎得到了解决。现在它返回oauth令牌: Codebird\Codebird对象([\u oauth\u token:protected]=>codehere[\u oauth\u token\u secret:protected]=>0[\u supported\u media\u files:protected]=>Array([0]=>1[1]=>2[2]=>3][\u版本:protected]=>3.0.0-dev[\u use\u curl:protected]=>1[\u超时:protected]=>10000[\u connectionTimeout:protected]=>3000) 但当我尝试推特时,我会出现以下错误: stdClass对象([errors]=>Array([0]=>stdClass对象([code] =>89[消息]=>无效或过期的令牌。)[httpstatus]=>401[速率]=>) 下面是我的代码Php Twitter代码鸟错误,php,twitter,twitter-oauth,Php,Twitter,Twitter Oauth,我正在尝试使用codebird使用PHP发送推文。起初我无法获取访问令牌,但在设置中定义CallbackURL后,这个问题似乎得到了解决。现在它返回oauth令牌: Codebird\Codebird对象([\u oauth\u token:protected]=>codehere[\u oauth\u token\u secret:protected]=>0[\u supported\u media\u files:protected]=>Array([0]=>1[1]=>2[2]=>3][\
Codebird\Codebird::setConsumerKey('copy+paste from twitter', 'copy+paste from twitter'); // I changed it to my settings
$cb = \Codebird\Codebird::getInstance();
if (! isset($_SESSION['oauth_token'])) {
// get the request token
$reply = $cb->oauth_requestToken(array(
'oauth_callback' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
));
// store the token
$cb->setToken($reply->oauth_token, $reply->oauth_token_secret);
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;
$_SESSION['oauth_verify'] = true;
// redirect to auth website
$auth_url = $cb->oauth_authorize();
header('Location: ' . $auth_url);
die();
} elseif (isset($_GET['oauth_verifier']) && isset($_SESSION['oauth_verify'])) {
// verify the token
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
unset($_SESSION['oauth_verify']);
// get the access token
$reply = $cb->oauth_accessToken(array(
'oauth_verifier' => $_GET['oauth_verifier']
));
// store the token (which is different from the request token!)
$_SESSION['oauth_token'] = $reply->oauth_token;
$_SESSION['oauth_token_secret'] = $reply->oauth_token_secret;
// send to same URL, without oauth GET parameters
header('Location: ' . basename(__FILE__));
die();
}
// assign access token on each page load
$cb->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
print_r($cb);
$params = array(
'status' => 'Auto Post on Twitter with PHP http://goo.gl/OZHaQD #php #twitter'
);
$reply = $cb->statuses_update($params);
print_r($reply);
提前感谢您的帮助。您的回拨地址是应用程序定义中在Twitter上注册的地址吗 你在应用程序定义中有“读写”权限吗 您是否已超过投寄的费率限制 我会先检查这些东西,因为我没有看到您的代码片段中明显缺少任何东西