How to use cURL and the Twitter API, November 2011 edition

I used to use cURL to interface with the Twitter API, but after they changed/restricted it, that became harder. However, with a bit of investigation, I can show you how to use them together still, at least for queries. (If anyone knows a simple way of doing updates, please comment below).

For example, if you want to get my timeline, you can use

curl http://twitter.com/statuses/user_timeline/blm849.rss

If you want to get 200 entries, you can use:

curl http://twitter.com/statuses/user_timeline/blm849.rss?count=200

If you want to get 200 entries and use JSON instead of RSS, you can use:

curl http://twitter.com/statuses/user_timeline/blm849.json?count=200

If you want to play around, replace “blm849″ with your twitter handle or someone else’s that isn’t protected.

For more on various formats and parameters, see GET statuses/user_timeline | Twitter Developers. Also make sure you check it for limits.

Here’s another option. If you want to get the statuses for the entries in my FAVS lists, you can use:

curl http://api.twitter.com/1/blm849/lists/favs/statuses.atom

If you go to the REST API Resources for Twitter Developers page, you can see other options.

Essentially you need to play around to take a command you send to the REST API (e.g. GET lists/statuses) and learn how to turn it around to a commend you can pass to twitter.com/api.twitter.com.

If you say: hmmmm, some of this is inconsistent, etc., I confess I have just started experimenting. But I wanted to get something down before I forgot about it, and I will build on it later.

Good luck!

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s