How to get a list of followers or following?


#1

When I set up my Foursquare account, I was able to send invites to all the people that I follow that have a Foursquare account. I’m looking for a way to get a list of people I follow. How is that done?


#2

Did you learn how to do this yet?


#3

If you just need the user ids of the users you are following or who follow you, then it’s usually a single API call. If you need the screen_names and other biographical data, you’ll need to chain API requests together.

The methods you are looking for are:

  • [node:22] and [node:21] for getting the ids
  • [node:63] to “hydrate” the user_ids into full user objects

#4
  <?php
  $trends_url = "http://api.twitter.com/1/statuses/followers/rohitfantasy.json";
  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL, $trends_url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $curlout = curl_exec($ch);
  curl_close($ch);
  $response = json_decode($curlout, true);
  foreach($response as $friends){
  $thumb = $friends['profile_image_url'];
  $url = $friends['screen_name'];
  $name = $friends['name'];

 ?>
<a title="<?php echo $name;?>" href="http://www.twitter.com/<?php echo $url;?>">

<?php
 }

#5

here is the code i am using for getting the list of followers…


#6

How to get a list of followers or following?


#7

The methods you are looking for are:

  • GET friends/ids and GET followers/ids for getting the ids
  • GET users/lookup to “hydrate” the user_ids into full user objects

#8
  • GET / IDS amigos e seguidores GET / IDS para obter o ids
  • GET usuários / pesquisa para “hidratar” os user_ids em objetos totais de usuário

#9

updated your print statement

<?php $trends_url = "http://api.twitter.com/1/statuses/followers/zkm.json"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $trends_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $curlout = curl_exec($ch); curl_close($ch); $response = json_decode($curlout, true); foreach($response as $friends){ $thumb = $friends['profile_image_url']; $url = $friends['screen_name']; $name = $friends['name']; print "" . ""; }

#10

How can I send messages after getting followers???


#11

also u can use the user_id

$trends_url = “http://api.twitter.com/1/statuses/followers/226841244.json”;


#12

Please anybody have full source to how to get name and followers.
eg. i am giving my twitter id and password it will display a no.of followers and name of current login user.


#13

Thank You


#14

Hei vijay, the code given by @rohitfantasy and @ZKM is correct way to get username by followers. if you just want to display username of your followers just echo $url.


#15

Hmm just wondering if it’s possible to get “mutual following”? It’s like fetching only the users you follow, and at the same time, they follow you back?


#16

any one know, i use this and work on my xampp

//Twitter Follower
$twit = file_get_contents(‘http://twitter.com/users/show/’.$user[‘twitter’].’.xml’);
$begin = ‘<followers_count>’; $end = ‘</followers_count>’;
$page = $twit;
$parts = explode($begin,$page);
$page = $parts[1];
$parts = explode($end,$page);
$tcount = $parts[0];
if($tcount == ‘’) { $tcount = 0; }
$tcount = number_format($tcount);
$Aipolow = ‘’.$tcount.’ Follower’;
echo ‘

  • Twitter: ‘.$Aipolow.’
  • ’;

    but when i use it on my site the count still 0


    #17

    I know to get more than the small list you have to use authentication. Does the code change though if you want the full list of followers?


    #18

    i just tried this code and its telling me that curl_init() has not been declared


    #19

    its working for me


    #21

    how to get the name of followers in ipython using twython