简体   繁体   中英

Get friends ids list in twitter API with TwitterOAuth

I have some problems to get list of friends of a twitter user, i use TwitterOAuth library.

$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'] is an array of user ID. When i use this code i only get my account friends list even user_id send is not mine.

Thanks for your help ^^ (and sorry for my bad English)

I find the problem.

To get friends/ids of another user authentification must be application-only. (see https://dev.twitter.com/oauth/application-only )

So i use this code ( https://gist.github.com/lgladdy/5141615 ) and now it's work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM