Twitter single url request - twitter

Is it possible to make a request to Twitter API in a single like? (http request?)
In example you can get the JSON in the Facebook API by the following single url:
https://graph.facebook.com/me?access_token=ACCESS_TOKEN
Can something be possible similarly in twitter. E.g.:
https://api.twitter.com/1.1/statuses/user_timeline.json?consumer_key=CONSUMER_KEY&consumer_secret=CONSUMER_SECRET&access_token=ACCESS_TOEKN&token_secret=TOKEN_SECRET
I find the twitter documentation quite stiff. If somebody has another proposal to get me understand how the communication with the API works I would be glad.

Related

Getting direct messages using Twitter REST api

I'm experimenting with twitter REST API with Ruby on Rails.
I'm using twitter gem for the same. I could get the client object using in my code.
client = current_domain.twitter_accounts.first.client
following the documentation given here
The client object works fine. But I couldn't get DirectMessages in the same way.
Also followed this documentation. Here I could not find a way to get DirectMessages. Is there a way in REST API to get twitter direct messages. Or do I need to implement Streaming API.
http://www.rubydoc.info/gems/twitter/Twitter/REST/Client
Methods included from DirectMessages
#create_direct_message, #destroy_direct_message, #direct_message, #direct_messages, #direct_messages_received, #direct_messages_sent
These map to the REST API endpoints
https://dev.twitter.com/rest/reference/get/direct_messages
https://dev.twitter.com/rest/reference/get/direct_messages/sent
n.b. you won't get group messages through this API and will need to rebuild an inbox model e.g. sequence replies of replies between yourself and the recipient.

Twitter api request

I have read the documentation of twitter , and created an app and have all the keys needed .
Now i am trying to understand that simple one line http request ,to get a user latest twits .
I have read this Simplest PHP example for retrieving user_timeline with Twitter API version 1.1
but there is not one line code in there to make the request ( i don't know java script).
so , i have this :
https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2
Which will not work because my keys should be in this line, but i don't understand how to add them?? where and how i add my keys to this ?
This url is like a node or address so twitter server knows what kind of request you need.
https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2
Beside url you can pass many other parameter using http header, which is best to be used with server langunge programming, e.g PHP.
In PHP you can pass your credentials by changing header. While current twitter API are using Oauth, it's going to difficult to learn using Oauth this way, the easiest option is to use others' library. Check out 'twitter API library' (just google it)

How to get and display API like the facebook graph in rails

I've went through most of the beginner rails books and I want to try creating something on my own. For a start, I just want to create a few pages in rails that will get from Facebook's api and display something like username, likes, post. I've searched around and couldn't find an answer. My friend recommended that I use a gem called fb_graph, but reviewing the documentation, I have no clue how to use it.
Thanks stackoverflow!
You can query the Graph API directly. The responses will be in JSON which you can then parse into Ruby hash. See the Facebook Documentation for more details on to call specific and sample JSON responses. So here is general guide how to you can start playing around with this:-
Make a API Call to Facebook using Graph API
Explorer. Keep playing around with api until you get a response you want. Note the request params you passed to get that response & JSON you received from facebook.
Send a HTTP request containing those same params in rails using koala, 'fb_graph' or just plain NET:HTTP. It doesn't matter what client you use to sent the request, as long as you send same params as in step1, you will get that familar JSON as response.
Now, once you have the json, just have to parse it. Provided, if the client library is not already doing that as most fb gems will turn JSON into ruby objects/hashes. But if they don't, then you have to do it manually, its something like JSON.parse('JSON_RESPONSE_AS_STRING_GOES_HERE'). after this you will have a plain-old ruby hash which is you can save to db, display in view or whatever you want to do.
Hope it helps

How to use Twitter User Streams

I am new in Twitter API. I have a requirement like I have to pull the information of an authenticated twitter user to know the number of followers. I can do this using REST API but I have a problem here. So I have taken the way to use Twitter User Streams.
I am not able to integrate this functionality in the site. I am using twitter console( https://dev.twitter.com/console ). But there I am not able to get any kind of result, it actually hangs/shows gateway timeout. And that's for I am not able to configure that how to write the code for this or how to use this in site. I am not passing any kind of parameters.
So, any body can please help in this would be very grateful( a clean sample code for this or any link where to get the good documentation ). I have already checked with twitter dev documentations.
Thanks in advance :)

How to get results with twitter search api?

I wish to get tweets with a keyword. But There is no result with any keyword.
http://search.twitter.com/search.json?q=summer
How to get results with Twitter Search API?
Version 1 of the twitter API has been deprecated and is being removed. Not sure how you can miss the giant warnings on the twitter dev site ;) This means simple code like the above will not work any more.
So, you now need to make authenticated requests (OAuth) using the 1.1 API, and it's nowhere near as simple as just doing a (in PHP) file_get_contents(http://search.twitter.com/ ...).
I couldn't see any server-side languages you use from your profile, but I wrote a lengthy post explaining the issue (with pictures) and how to use a php library to perform authenticated requests.

Resources