Showing latest tweet using Twitter Stream API

Go To StackoverFlow.com

0

I need to show the latest tweet of a specified user using the twitter stream API. I have moderate PHP, JSON and Javascript knowledge but not enough to figure out this twitter stream API on my own. Can someone explain to me what it would look like to "connect" to this twitter stream and display the latest tweet? Does something need to be done on the actual server, or can this all be done just through some json and php code in the website template?

2012-04-04 19:46
by taylor
"Does something need to be done on the actual server, or can this all be done just through some json and php code in the website template?" - The PHP code is always run on the server, even if it is within your template - Christofer Eliasson 2012-04-04 19:49
if your using the 140 Dev server, the tweets gets pulled into a special database table you can easily configure with the config files included in the zip - Chamilyan 2012-04-05 09:21


0

You don't want to use the streaming API for this.

You'd want to fetch statuses/user_timeline and parse it. You could load it and parse it entirely via JavaScript, in fact, avoiding any need to do PHP work here.

2012-04-04 19:51
by ceejayoz
I go past the hourly max amount of twitter requests within 5 minutes using the regular way to fetch and parse the latest twitter status. This is why I am trying to learn how to connect to and use the Twitter Stream API, so that I can avoid the hourly request cap - taylor 2012-04-04 19:56
You can avoid the hourly request cap by caching the response (PHP has a number of ways of caching stuff - writing it to a file, storing it in APC, a database, etc.) for a minute or two - ceejayoz 2012-04-04 20:04
Incidentally, if you're creating and tearing down a connection to the Streaming API every time the page is viewed, you'll hit a cap there as well - ceejayoz 2012-04-04 20:11
Or like ceejayoz said, use Javascript, works wonder - Chamilyan 2012-04-05 09:12


0

If your set on using the Streaming API for whatever reason. What you could do is use something like PHP phirehose or to make it even easier as in dead simple easy. Look into and read the information posted about the 140 DEV Server by Adam Green.

His website is here: http://140dev.com/

and you can download the PHP framework/server from here: http://140dev.com/free-twitter-api-source-code-library/twitter-database-server/download/

2012-04-05 09:19
by Chamilyan
Ads