Code Snippets Gallery
Display Last Tweet
$.getJSON("http://twitter.com/statuses/user_timeline/username.json?callback=?", function(data) {
$("#twitter").html(data[0].text);
});Make sure you change username.json to your actual username and #twitter to the actual selector you wish to update.
Love it!
But how can I show the last several tweets?
Add this
callback=twitterCallback2&count=1after this
callback=?Change the 1 to as many as you’d like.
I mean, replace the
callback=?with the first code.I tried to use the
It doesn’t seem to work for some reason…
Connecting to Twitter…
Yeah, similar sort of thing, can get the one on it’s own to work, but no more than that…
For those having an issue with more than one item, it’s because you have to put it inside of an array if it’s more than one item.
Something like:
instead of:
use
Will Twitter limit the number of jSON requests my server makes? In other words, if my site gets 1000 hits per hour should i be caching the tweet in a database? Or does twitter see it as the client making the request rather than my web server?
This site does OK without it… but… I probably should be caching. Caching something like this is just a good practice period. Regarding the limits, I’m not sure there is on stuff like just pulling from the timeline. I think it’s stuff like search that is limited. Could be wrong though.
you can also refer to this site on how to display your latest tweets in twitter. with twitter API.
http://www.ryscript.co.cc/web/how-to-display-latest-tweets-using-javascript-and-twitter-api/
thanks..
what if i dont want to get tweets from twitter i want to show it from my own mysql database any suggestions ?
Nice simple code..
I gonna use that one..
Thanks