0

I am using the Twitter GET search for retrieving tweets from a specified account, hashtag etc. etc.. But the Twitter GET search has it's limitations: it has a timelimit of 6 to 9 days of visible tweets. That's where I want to make sure there are always three tweets visible on the website.

The problem is I can't just add the entire xml string to a database (tried that, and it works, but if there is a new tweet when the others are not visible anymore I'm stuck with 1 tweet instead of 3 when it updates) and need to target individual nodes of the xml-file.

The point is that I want to retrieve new tweets, but 'close the gap' with the older tweets (in case there are less than 3 tweets in the GET search).

I still want to save a xml string to the database, but with the backup-plan as described above. I want to use php for this xml-string modifying. Does anyone have suggestions on this? I tried simpleXML, but this has it's limitations (e.g. reading, editing or deleting of an object's nodes).

I am aware of the Twitter Stream API, but I just can not get hold of how it works, that's why I am trying it with the GET search.

j0k
  • 22,600
  • 28
  • 79
  • 90
Jeroen
  • 345
  • 3
  • 17

1 Answers1

0

Why don't you:

  1. Get the search XML
  2. Parse it to extract each tweet
  3. Store each tweet in a table (with the tweet_id as PK)
  4. Continue to fetch the search
  5. if the last tweet from the search is different than the last tweet from the database, you integrate it
  6. back to 4. and loop

This way, you will always have XX tweets available. And you can purge the table when you have XX tweets inside to keep fresh tweet inside.

After that, you can improve the way you find if a tweet is on your side or not. But I think it's a good start.

j0k
  • 22,600
  • 28
  • 79
  • 90
  • woops.. didn't think of that.. That's way easier indeed! I'm sure this will work out for me. Thanks! – Jeroen Aug 21 '12 at 16:25