我的问题很奇怪(至少对我来说),因为我有一个请求URL在控制台中工作,但在我的PHP脚本中抛出了Sorry, that page does not exist
错误,即使连接已启动并正在运行。Twitter API - 如何检查用户A是否跟随用户B
所以这
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_secret']);
$user = $connection->get('account/verify_credentials');
print_r($user);
的伟大工程,在$用户数据被打印在屏幕上。
但是,我无法检查的友谊状态:
$x = $connection->get('https://api.twitter.com/1.1/friendships/show.json?source_id=707482092&target_id=755811768&target_screen_name=assetspersonifi');
当我得到的错误。
当我将这个请求放入Twitter API控制台时,它将返回json,我没有在我的php代码中收到这个请求。
我使用Abraham's twitteroauth library但是,这并不工作之一:
$follows_faelazo = $connection->get('friendships/exists', array('user_a' => 'blfarago', 'user_b' => 'faelazo'));
if(!$follows_faelazo){
echo 'You are NOT following @faelazo!';
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
} else {
print_r($follows_faelazo);
}
stdClass Object ([errors] => Array ([0] => stdClass Object ([message] => Sorry, that page does not exist [code] => 34)))
我读了friendships/exists
API是由Twitter的API不再支持,我应该使用friendships/show
但如何,如果你看到它不工作以上?
为了证明别人是工作的一切,我可以跟着别人用
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
为什么?
这是一个明确定义的问题,显示我需要什么,我尝试了什么,为什么downvote? – erdomester
1.确保您已更新API版本变量(https://github.com/abraham/twitteroauth/blob/master/src/TwitterOAuth.php#L18)2.考虑使用用户标识('source_id' 'target_id')。你能确定这些用户真正存在吗? –