Displaying only screen_name from friends/list


#1

Hi I am using https://github.com/abraham/twitteroauth and have changed:

$content = $connection->get(‘account/verify_credentials’);

to $content = $connection->get(‘friends/list’);

and it is showing all my friends info ok but I need a way to get only the screen names so that I can add them to a database.

Have been trying this for days and haven’t got close so I am back to square 1 and could really use some help


#2

The friends/list method is one way to go about this. It provides a cursored collection of user objects, but only a very small amount at a time. You have to make several requests to collect all the user objects. You can then extract the screen_name from each of those user objects.

Another alternative is to use friends/ids instead, which return up to 5000 user IDs per request. To turn those into screen names, you’d then have to pass 100 of those IDs at a time to users/lookup.

Either way, for most accounts you’ll need to make a series of requests to assemble this information together. [node:10362] has some pointers on how to work with cursors.