Created
June 29, 2011 05:33
-
-
Save hulbert/1053218 to your computer and use it in GitHub Desktop.
Javascript functions to filter out replies from Twitter API JSON
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
// 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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