我正在尝试使用oAuth更新Twiiter中的某些状态。但是当我尝试连接到twitter时,它显示的是有效或过期的令牌,确切的消息是
stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Invalid or expired token [code] => 89 ) ) )
为什么显示此错误?我在会话中获取令牌和令牌秘密值,但它显示错误。
这是我的PHP代码。
<?php
session_start();
define('OAUTH_CALLBACK', 'http://somedomain.com/twitter/index.php');
require_once('twitteroauth/twitteroauth.php');
if(!isset($_GET['oauth_token']) && !isset($_GET['oauth_verifier'])){
$connection = new TwitterOAuth('kvKZRppWiAKkMexUQTCSqA', 'tMK1QfjPFNmIMHcKM4YVAMenvzS31JWerhjAf4q8');
/*$account = $connection->get('account/verify_credentials');
print_r($account);
$status = $connection->post('statuses/update', array('status' => 'Text of status here', 'in_reply_to_status_id' => 123456));
*/
$temporary_credentials = $connection->getRequestToken(OAUTH_CALLBACK);
$_SESSION['oauth_token'] = $token = $temporary_credentials['oauth_token'];
$_SESSION['oauth_token_secret'] = $temporary_credentials['oauth_token_secret'];
$redirect_url = $connection->getAuthorizeURL($temporary_credentials);
header('Location:'.$redirect_url);
//print_r($redirect_url);
}else{
$oauth_token = $_SESSION['oauth_token'];
$oauth_token_secret = $_SESSION['oauth_token_secret'];
print $oauth_token;
print $oauth_token_secret;
$connection = new TwitterOAuth('kvKZRppWiAKkMexUQTCSqA', 'tMK1QfjPFNmIMHcKM4YVAMenvzS31JWerhjAf4q8',$oauth_token ,$oauth_token_secret);
$account = $connection->get('account/verify_credentials');
print_r($account);
}
有人可以帮助我吗?