tags:

views:

150

answers:

4

I'm trying to figure out a way to pull all tweets of a specific search term via PHP and the Twitter search api.

So functionality would include 1. Include a search term 2. Pull terms from each page. 3. Only pull new terms from last search 4. Export to a db or a flat file.

I'm pretty clear on all of these except for traversing across multiple pages

A: 

The search API has a page parameter:

page: Optional. The page number (starting at 1) to return, up to a max of roughly 1500 results (based on rpp * page. Note: there are pagination limits.

Example: http://search.twitter.com/search.atom?q=devo&rpp=15&page=2

Does that help?

dirkgently
A: 

The twitter search api takes a page parameter:

# page: Optional. The page number (starting at 1) to return, up to a max of roughly 1500 results (based on rpp * page. Note: there are pagination limits.

* Example: http://search.twitter.com/search.atom?q=devo&rpp=15&page=2
Greg
+5  A: 

The twitter API takes a page number parameter. In the atom results, there are link elements, with rel attributes for next and previous. This will be your best indicator as to whether you should go looking for a 2nd page and so on. The href attribute of that tag will even tell you the URL you should request.

The query you create also takes a since_id parameter. You'll want to store the largest id number you see in your responses and use it in subsequent requests so that you don't have to filter duplicates.

As for data storage, your selection is probably best guided by what you plan to do with the results... if you're going to be doing any querying, you should probably file it away in a database, i.e. MySQL. If you're just logging, flat file should do you fine.

great_llama
Just be sure not to use the deprecated since_time parameter anywhere, it'll return some truly unwanted data :)
James Burgess
A: 

Thanks everyone it is working nicely. Is there a way to determine how many pages were returned?

Tim