Tyilo
Tyilo

Reputation: 30102

Get list people you are following on twitter

IS it possible to something like this:

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

but instead of list of people following you, list of people you are following?

Upvotes: 15

Views: 20908

Answers (4)

Evan
Evan

Reputation: 1737

Looks like this is what you need:

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

Once you have the list of ID's returned, you can look them up by passing them as a comma delimited list to another API call:

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

Upvotes: 14

Vikram Srivastava
Vikram Srivastava

Reputation: 39

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);

Upvotes: 0

Sylvain Carle
Sylvain Carle

Reputation: 49

The new 1.1 URL you need to call is https://api.twitter.com/1.1/friends/ids.json

Full documentation is at https://dev.twitter.com/docs/api/1.1/get/friends/ids.

Upvotes: 3

bitboxer
bitboxer

Reputation: 554

You could use this:

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

that way you don't have to do two calls for id and than for details.

Upvotes: 6

Related Questions