开发者

Twitter API calls (similar to how Facebook API is done?)

开发者 https://www.devze.com 2023-01-20 16:37 出处:网络
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?

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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消