Skip to content

Instantly share code, notes, and snippets.

@dshah22
Forked from UnquietCode/gist:3711511
Last active March 18, 2016 19:32
Show Gist options
  • Save dshah22/261f362994e0702c9511 to your computer and use it in GitHub Desktop.
Save dshah22/261f362994e0702c9511 to your computer and use it in GitHub Desktop.
Extract tweet info from the basic Twitter timeline widget.
<html>
<head>
<script type="text/javascript" src="jquery-1.8.1.min.js"></script>
<script type="text/javascript">
<!-- use the url that your twitter widget is using to retrieve the tweet data -->
$(function() {
$.getJSON("http://cdn.syndication.twimg.com/widgets/timelines/WIDGET_ID_HERE?dnt=true&domain=unquietcode.com&lang=en&callback=?", function(data) {
var tweets = $(data.body).find('li.tweet');
Tweets = [];
for (var i=0; i < tweets.length; ++i) {
var cur = $(tweets[i]);
var tweet = {};
tweet.authorFullName = cur.find("span.full-name span.p-name").html();
tweet.authorUserName = cur.find("span.p-nickname b").html();
tweet.date = cur.find("a.u-url").attr("data-datetime");
tweet.id = cur.attr("data-tweet-id");
tweet.text = $.trim(cur.find("p.e-entry-title").html());
Tweets.push(tweet);
}
});
});
</script>
</head>
<body>
<div>Hi mom!</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment