Created
November 19, 2012 12:17
-
-
Save ArupSen/4110355 to your computer and use it in GitHub Desktop.
Grab Twitter Feed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Grab Twitter Feed | |
Look at the url of the api that will change to /1.1 from march 2013 | |
callback=twitterCallback2 still works | |
http://twitter.com/statuses/<username>.json? no longer works | |
*/ | |
function init_twitter() { | |
$.getJSON('https://api.twitter.com/1/statuses/user_timeline.json?screen_name='+ twitterID +'&count=1&callback=?&include_rts=true', function(data){ | |
var tweet = data[0]; | |
var tweetID = tweet.id_str; | |
var tweetText = linkifyTweet(tweet.text); | |
var timeago = relativeTime(tweet.created_at); | |
var permalink = 'http://twitter.com/pixelunion/status/' + tweetID; | |
var fullname = tweet.user.screen_name; | |
var output = $('<p class="tweet">' + tweetText + '</p>'); | |
var timestamp = $('<a class="timestamp accent-text" href="' + permalink + '" time="' + tweet.created_at + '" target="_blank">' + timeago + '</a>'); | |
var user = $('<a href="http://www.twitter.com/'+ twitterID +'" class="twitter-name">'+ fullname +'</a>'); | |
var twitter_avatar = $('<img src="'+ tweet.user.profile_image_url_https +'">'); | |
output.appendTo('.tweet-area'); | |
user.appendTo('.twitter-names'); | |
timestamp.appendTo('.twitter-names'); | |
twitter_avatar.appendTo('.twitter-avatar'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment