How can one learn to use the twitter API? - rest

Ok before you jump to some conclusion like I'm looking for a free lunch or something of the sort, read the description entirely.
I have experience only in making small simple apps in PHP, Java and ASP.NET. I had no idea what GET, SET etc exactly are and what REST services are. To try to use the Twitter API, I did some reading and got to know (I might be wrong here, because this is what I THINK that I know..) that you can make a GET request like this one:
http://api.twitter.com/1/statuses/user_timeline.json
Using, say, cURL (I haven't tried it yet), and you get a JSON object returned which contains the statuses on your timeline in a certain format. And I verified this from here
But I don't understand how does Twitter know that it is ME and return only MY data? Where am I sending my account details?
What I want is for the use to come to my website, click a button to give my application the permission to access his/her Tweets and I do some processing in PHP and display the output. But I don't know where do I start from?
I am not asking you to give me bread, I'm asking you to tell me what should I do to learn to fish?
All tutorial I have been following till now have been sort of spoon fed where they say things like 'Download this php file from our site, include it in your source file, use this method to do this and that method to do that.'
This one is a change for me, so does anyone have any pointers? Is there any reading that I should do or approach that I must follow to learn that I'm doing wrong?
EDIT : I know there are 3rd party libraries out there and it might be easier to learn to use those, but I want to have an idea of how the people who made those did it.

To use Twitter (at least its REST API), you had better to read tutorials about the following things :
REST architecture because it is how Twitter communicates with your application.
HTTP requests. Useful for Authentication of requests (HTTP headers), kinds of HTTP requests (GET and POST for the Twitter API) and return codes of requests.
OAuth which is the protocol used by Twitter for authenticating requests.
Format of datas returned by Twitter after the requests. Most of the time it is JSON but it can also be like in a URL query string (for OAuth authentications). You are lucky because before there were XML and Atom (for RSS feeds) too.
And of course the Twitter Documentation to know how they use all that stuff, how they know that is YOU with THIS application (request authentications) and to know the objects manipulated by the API (mainly tweets, users and timelines).
Good luck for it !

Related

Non-ssl API: Registration and subsequent authentication

I am building an api for my first app, which consists of both a web based app grafted onto an existing website, and a mobile Cordova app. I am still something of a noob to concepts of authentication and security, so I am just trying to get an idea of the basics, and want to make sure I'm not missing something obvious. So far here's what I've got:
The server currently is non-ssl. I am registering users by making a POST request to the API with the plain text username and password appended as form data. An api key is then generated for the user which is returned to them, which they will then use for subsequent requests by including it in the header.
OK, so... given that this app isn't handling particularly sensitive data, and I only really care about basic-level security, is this acceptable? Is there any obvious and simple step I could take to improve the above setup?
Thanks.

How to retrieve user information after login with RESTful services

What should be the standard approach for getting user information after login ?
POST request to validate user/password and retrieve information on response
POST request to validate user/password followed by GET request to retrieve information?
As far as I understand, GET should be the preferred one to retrieve data, but it seems burdensome to performe two requests; at the same time, it feels weird to get data back on POST response. Which should be preferred?
My 2 cents:) if you really want to follow REST Paradigm then you should use standard http method as GET. Although an overloaded POST might do the job however it’s not following the standard.
In SOAP world everything is POST and you can do a lot of funky stuff however in REST world there is a standard on what method used for what purpose ideally.

Best way to post to a wamp database from mobile app

I'm setting up a website using CakePHP and a corresponding mobile application. At various times, I need the mobile application to post information to the website and have that information be stored in a database table. I've looked at RESTful APIs and how to use them in CakePHP but I'm not sure if that's what I want. Most of the information I've read seems to indicate that RESTful APIs are helpful for getting information from the server to the client, not vice versa.
Can somebody point me in the right direction for how to do this? Let me know if I was being ambiguous or you need more information. Thanks for the help.
Well, read again about RESTful webservices, try this section:
http://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_APIs
You use the HTTP methods GET, PUT, POST, or DELETE to read, update, create or delete resources from your site. The RESTful page in the official CakePHP documentation explains that concept with examples pretty well.

Read my Facebook application's publish stream posts

I created a number of posts on behalf of the user by issuing an HTTP POST request to (PROFILE_ID/feed) with the publish_stream. Sample:
https://graph.facebook.com/me/feed?
I got everyone's post ids, but I when I'm trying to access and read them I getting a "false" respond..
I was at a Perl Mongers meeting (Los Angeles) last week where the presentation was on integration with Facebook. In particular, one of the developers was discussing his new module, Facebook::Graph. He indicated that in producing the module he learned a lot about what Facebook would do if you request information but don't provide everything it is expecting in your request. Your problem description sounds like a case in point.
The module's description is:
This is a Perl interface to the Facebook Graph API
http://developers.facebook.com/docs/api. With this module you can
currently query public Facebook data, query privileged Facebook data,
and build a privileged Facebook application. See the TODO for all that
this module cannot yet do.
There is a companion POD for that module called Facebook::Graph::Cookbook. It contains a couple of cookbook examples.
While the module is still fairly new and under development, I know that the individual who worked on it has spent many hours working on it in a professional setting where solid results are expected. I'm confident that he "got it right." It's currently being used by a high-traffic well known website.
There's no point trying to re-implement interfacing with this API when someone else has done a good job of it already. Through the discussion that took place after the presentation I know that the module has gone through extensive testing. That's not to say it's perfect, but it's probably a hundred or more man-hours further along the journey.
It's my suggestion that you implement your Facebook Graph interactions through using this module. I suspect when you do, many of your headaches will go away.
You'll need to ask for the read_stream permission to do this

How do i use an API

I've never used an API and was wondering how you use them... I would like to use facebook, twitter and vimeo's api,
Can someone explain the basics of using them, how do i access them and use them etc.
Please and thanks
Neil
How to use an API depends on the API. Usually the API creator has documentation on how to use their specific API.
Mostly, things work like the following:
You register to get a developer key. Then, you send requests to the service via HTTP (for example Twitter is using REST, which requires you to send XML or JSON to a specific http-URL providing your key). You get an answer from the service, which you must then parse and react to accordingly (for example filling a list with contacts, etc.).
Most of the time this all comes down to:
Create an XML or JSON document that describes the call parameters
Send the document to an URL using GET, POST or other request methods
Get the server's response
Parse and evaluate the response
The specific ways to use the API, especially performing authentication, can be found on the service's developer pages.
The best way to start if you want to use an API is to read it's documentation, find some tutorials and code examples. This is always/usually published by the one offering an API.
Good luck :)