获取您在Twitter上关注的人员列表

时间:2011-08-06 15:31:47

标签: twitter

是否有可能出现这样的事情:

http://api.twitter.com/1/statuses/followers/xxxxxx.json

,而不是关注您的人员列表,您关注的人员列表?

4 个答案:

答案 0 :(得分:12)

看起来这就是你需要的:

https://api.twitter.com/1.1/friends/ids.json?id=:screen_name_or_user_id

https://dev.twitter.com/docs/api/1.1/get/friends/ids

获得返回的ID列表后,您可以将它们作为逗号分隔列表传递给另一个API调用来查找它们:

http://api.twitter.com/1.1/users/lookup.json?user_id=[comma delimited list goes here]

https://dev.twitter.com/docs/api/1.1/get/users/lookup

答案 1 :(得分:6)

你可以用这个:

https://api.twitter.com/1/friends.json?screen_name=bitboxer

这样你不必为id而不是为细节做两次调用。

答案 2 :(得分:3)

答案 3 :(得分:0)

require_once('tmhOAuth.php');
require_once('tmhUtilities.php');
$profile_username = "abcdefg"; //twitter username
$oauth_access_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Your access token
$oauth_access_token_secret = "YYYYYYYYYYYYYYYYYYYYYYYYYY"; //Your access token secret
$consumer_key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; //Your key
$consumer_secret = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; //Your secret key
$tmhOAuth = new tmhOAuth(array(
    'consumer_key' => $consumer_key,
    'consumer_secret' => $consumer_secret,
    'user_token' => $oauth_access_token,
    'user_secret' => $oauth_access_token_secret,
    'curl_ssl_verifypeer' => false
));
$code = $tmhOAuth->request(
    'GET', 
    $tmhOAuth->url('1.1/friends/ids'), 
    array(
        'screen_name' => $profile_username,
        'count' => '10'
    )
);
$response = $tmhOAuth->response['response'];
$following_ids = json_decode($response, true);
print_r($following_ids);