[On Special Request] How to Query the Twitter trends API to get latest trends in real time
hi,
I was just contacted by a reader of my blog Mikel Iturrioz, an internet passionate (as he claims himself to be) and had reached my blog through a client project available http://clients.nishantarora.in/projects/twitter_trends/. Now since it is a client project and I have been paid to do this, I doubt I can share this code freely, but the idea is something available for free and let me try to explain what I did here.
Step 1: Understanding the twitter trends API:
you can get the latest country trends by getting the URL http://api.twitter.com/1/trends/
Here is a List of some common WOEIDs in PHP array format:
Step 2: Creating a simple function to get trends from what we have learnt above
Does the following function need any explanation?...
Step 3: Outputting the data.
I think this is the most easiest part...
Checkout this in action here http://clients.nishantarora.in/projects/twitter_trends/?id=23424977
Step 4: Adding AJAX Magic (OPTIONAL)
this is totally upto you how you wanna interface that with the data on your website. you can add some fancy AJAX or can just reload on a new request, Sky's the Limit
Hope I explained every bit of it, clearly and as easy as possible. Thanks to my readers, this really encourages me!
Cheers!... Keep Hacking!...