views:

31

answers:

1

Hi all,

I understand that the Twitter API documentation is fairly substantial, but I was wondering if there is simple way to access Twitter API which is similar to Facebook's API?

For instance, we can access facebook's APi as follows:

https://graph.facebook.com/btaylor?access_token=dfjsmdjfsmjfsmljfd

Notice the parameter access_token appended to the URL.

Can we do something similar in Twitter's API ?

For instance: http://search.twitter.com/search.json&access_token=dklfjsdkljfskldf

Is it possible? Or am I missing something?

Best Regards.

+3  A: 

If you just need to search Twitter, then you don't have to use the API. For example, if you want to search for "django", simply request https://search.twitter.com/search.json?callback=?&q=django and you'll get your json.

Using the API requires that you first use OAuth to authenticate (Basic authentication is no longer supported). If you are familiar with the Facebook API, then perhaps you are familiar with oAuth already, as the Facebook API also uses OAuth.

Once you have the authorization info for your user, you don't pass it in URL, but in the request header, along with the URL for what you want, such as http://api.twitter.com/1/statuses/home_timeline.json if you want the user's home timeline.

If you've registered a Twitter application, then you can use Twitter's API console at http://dev.twitter.com/console to see what various requests and responses look like.

Here's a full header example:

GET /1/users/show.json HTTP/1.1
Accept: */*
Connection: close
User-Agent: OAuth gem v0.3.4.1
Authorization: OAuth oauth_nonce=\"ijasef982JIOase09u23f90ha3f9u53OWEIFH249A1X\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1287510730\", oauth_consumer_key=\"091oi0uJH23h080hfaAF2z\", oauth_token=\"1515151-X09WeowihwefOIWEOFIHWEFo09823408924f08heFK\", oauth_signature=\"Jht%2FEk98092j3fSAI0923fLXpw%3D\", oauth_version=\"1.0\"
Host: api.twitter.com
schellack
One note is that in addition to the token being in the request header, each request also needs to be signed.
Owen
Thanks for the reminder. I went back and added an example header to show the full authorization section.
schellack
hello, thank you!
DjangoRocks
hello, thank you! May I know how does request header works? As in how does the code look like, say using Python ? (sorry i still have limited programming knowledge).
DjangoRocks
You'll likely want to take a look at one of the Python Twitter libraries out there (plus an OAuth library). Here are the ones listed by Twitter: http://dev.twitter.com/pages/libraries#python
schellack

related questions