Skip to content

Instantly share code, notes, and snippets.

@hulbert
Created June 29, 2011 05:33
Show Gist options
  • Save hulbert/1053218 to your computer and use it in GitHub Desktop.
Save hulbert/1053218 to your computer and use it in GitHub Desktop.
Javascript functions to filter out replies from Twitter API JSON
// This filters out replies (that Twitter understands are replies)
function has_in_reply_to_status_id(tweet) {
if (tweet.in_reply_to_status_id === null) return false;
else return true;
}
// This filters out tweets that start with a mention, which are almost always replies
function is_user_mention_at_start(tweet) {
if (tweet.entities.user_mentions.length > 0) {
if (tweet.entities.user_mentions[0].indices[0] === 0) return true;
}
}
@hulbert
Copy link
Author

hulbert commented Jun 29, 2011

This would be used with a feed from the Twitter API, something like this URL: http://api.twitter.com/1/statuses/user_timeline.json?screen_name=hulbert&count=20&callback=twitterCallback&include_entities=1&include_rts=0

I'm using it with a modified version of Twitter's old Blogger Javascript, original found here: http://twitter.com/javascripts/blogger.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment