使用TwitterOAuth在twitter API中获取好友ID列表


Get friends ids list in twitter API with TwitterOAuth

我在获取推特用户的朋友列表时遇到了一些问题,我使用了TwitterOAuth库。

$oConnection = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret);
$armFollow = array();
foreach($_POST['user'] as $nUsrId) {
    $armFollowList = $oConnection->get("friends/ids", ["user_id " => $nUsrId]);
    $armFollow[$nUsrId] = $armFollowList->ids;
}
var_dump($armFollow);

$_POST['user']是用户ID的数组。当我使用这个代码时,我只得到我的帐户好友列表,即使user_idsend不是我的。

谢谢你的帮助^^(并为我糟糕的英语感到抱歉)

我发现了问题。

若要获取另一个用户的好友/ID,身份验证必须仅限于应用程序。(参见https://dev.twitter.com/oauth/application-only)

所以我用这个代码(https://gist.github.com/lgladdy/5141615)现在开始工作了。