Get all members of twitter lists


/ Published in: PHP
Save to your folder(s)

To follow all of members in a list, you may want to use http://tweepml.org/


Copy this code and paste it in your HTML
  1. <?php
  2. define('TWITTER_CONSUMER_KEY', '');
  3. define('TWITTER_CONSUMER_SECRET', '');
  4.  
  5. $baseUrl = 'http://api.twitter.com/1/zuzara/in-japanese/members.json';
  6. // you will find tokens on My Access Token via http://dev.twitter.com/
  7. $accessToken = '';
  8. $accessTokenSecret = '';
  9.  
  10. $oauth = new OAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
  11. $oauth->setToken($accessToken, $accessTokenSecret);
  12. $url = $baseUrl;
  13. do {
  14. $oauth->fetch($url);
  15. $buf = $oauth->getLastResponse();
  16. $data = json_decode($buf, true);
  17. foreach ($data['users'] as $user) {
  18. echo $user['screen_name'], PHP_EOL;
  19. }
  20. $url = $baseUrl . '?cursor=' . $data['next_cursor'];
  21. } while (!empty($data['next_cursor']));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.