当试图简单地提到一个正确验证的帐户时,我会得到以下JSON:
"mentions": {
"errors": [
{
"message": "Sorry, that page does not exist",
"code": 34
}
]
},
我用来登录并生成它的代码如下:
private function get_twitter( $json ) {
$_SESSION['access_token']['oauth_token'] = ACCESS_TOKEN;
$_SESSION['access_token']['oauth_token_secret'] = ACCESS_TOKEN_SECRET;
/* If access tokens are not available redirect to connect page. */
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
/* Load and clear sessions */
session_start();
session_destroy();
if (CONSUMER_KEY === '' || CONSUMER_SECRET === '' || CONSUMER_KEY === 'CONSUMER_KEY_HERE' || CONSUMER_SECRET === 'CONSUMER_SECRET_HERE') {
$json['twitter_login_prompt'] = 'You need a consumer key and secret. Get one from <a href="https://dev.twitter.com/apps">dev.twitter.com/apps</a>';
exit;
}
/* Build an image link to start the redirect process. */
$json['twitter_login'] = '<a href="./redirect.php"><img src="./images/lighter.png" alt="Sign in with Twitter"/></a>';
}
/* Get user access tokens out of the session. */
$access_token = $_SESSION['access_token'];
/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
/* If method is set change API call made. Test is called by default. */
$json['twitter_verify'] = $connection->get('account/verify_credentials');
$json['mentions'] = $connection->get('/1/statuses/mentions');
return $json;
}
答案 0 :(得分:0)
您使用的api版本已被弃用 https://dev.twitter.com/docs/api/1/get/statuses/mentions
请考虑转向使用1.1版本的Twitter API: https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline
您可能希望使用以下说明:
$json['mentions'] = $connection->get('/1.1/statuses/mentions');