tags:

views:

387

answers:

3

This is really just for my own use: I would like to be able to search all of my updates, ever. Twitter's search (http://search.twitter.com) is time-limited - it only seems to search the last few weeks of updates, so it is difficult to find something I had posted months ago.

+2  A: 

To get a list of messages from a user you can use Twitter API but you'll need a user & password for some of the calls like the one you need:

Example for a max of 200: http://twitter.com/statuses/user_timeline.xml?count=200

You can use other parameters like "since" or other formats differents to XML. Click here for more info

ozke
I just tried this, but Twitter's response is an error in the XML file saying "Not Found". Do I need to setup the Twitter API for my account somehow?
Drew Stephens
Hmm, so it looks like this just uses my logged-in user if I request http://twitter.com/statuses/user_timeline.xml?count=200Thanks for the tip! Could you edit the URL in your answer to reflect that?
Drew Stephens
Done. user_timeline.xml is now the example URL
ozke
+1  A: 

First, you must be authorized to view the user account (otherwise you will never get the user's whole timeline). There are two ways to achieve authentication: you can either log in with the user's credentials or acquire an OAuth authentication token. The OAuth method is definitely the way to go, there is almost never a good reason to use the actual credentials and users are weary of supplying their login data to random applications.

Once you have the OAuth token, you can make a call to the REST API to get the user's timeline with

http://twitter.com/statuses/user_timeline.format

Where format stands for the preferred output format your application digests (right now xml, json, rss and atom are supported).

Besides the obvious *user_id* parameter, the count and page parameters are important for your purposes. count allows you to specify how many results you would like to get back (up to 200) and page is for the page number you would like to get back. All in all, you can get the last 3200 updates for any given user (for any combination of count x page).

To avoid unnecessary crawling, your application should contact the Twitter API for current statuses a few times a day in the background. Be aware that there are per-user limits on how often you can make queries to the Twitter server so local caching of status messages is a must.

Use the search API only if you absolutely must. For your scenario it's almost certainly not warranted.

You can find the API documentation for the statuses/user_timeline call here. And an excellent PHP module for OAuth/Twitter is available from Abraham Williams via github.

Udo
The OAuth method is still buggy... For example if our company used OAuth we would have had a broken application for close to 70 hours. Id wait a bit until twitter gets their shit straightened out.
Chad Scira
Generally, there is no excuse for using a person's actual credentials to log in. I know, Facebook does it with GMail and so on, but it's still a security nightmare. And that's exactly what OAuth solves. Twitter outages come in all forms and shapes, but that's no reason to prefer a direct login in my opinion.
Udo
+1  A: 

heres a trick

http://twitter.com/statuses/user_timeline/username.xml?count=1000&since=0

the since param allows you to override the default count max :) so now you can get a ton of updates without having to traverse pages.

Chad Scira

related questions