Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter search (atom) API - exclude retweets

I am using the Atom search API from Twitter. Now I present all (newest 5) tweets with a certain word. But unfortunately, many people retweet this one post and I get the same post 5 times.

Can I exclude retweets? If so, how?

like image 519
planIT Avatar asked Sep 13 '11 10:09

planIT


People also ask

Is there a way to exclude retweets?

You can turn off Retweets for a specific account if you don't like what they share. Select Turn off Retweets from an account profile page to stop seeing Tweets they've Retweeted (tap the gear icon on iOS or click or tap the overflow icon on web and Android).

How do you filter a retweet in Python?

If you fetch tweets using the tweepy library of python then you can achieve filtering retweets by appending “ -filter:retweets” to the search query. The code will look something like this: for status in tweepy. Cursor(api.search,q=query+" -filter:retweets",lang='en',result_type='recent').

How do you exclude a word from Twitter search?

Click the Privacy and safety tab, then click Mute and block. Click Muted words. Click the plus icon. Enter the word or hashtag you'd like to mute.


2 Answers

I've been successfully excluding retweets by adding +exclude:retweets at the end of my search query.

like image 138
peterkuterna Avatar answered Sep 29 '22 09:09

peterkuterna


I've done that and I'll share how you accomplish this. This would be your search query:

http://search.twitter.com/search.atom?lang=en&rpp=100&q=[yourpost-value]-filter:retweets

This will exclude the retweets 100% and it worked for me :). If you have a problem with this, here is the alternate way:

Concatenate -filter:retweets within the function you are calling, here is an example:

if(isset($_POST['q'])){
  $q = $_POST['q']."-filter:retweets";
} 

Now you just need to execute you search query:

http://search.twitter.com/search.atom?lang=en&rpp=100&q=[post-value]

I hope this helps, have fun with programming :)

like image 35
waqar ahmed Avatar answered Sep 29 '22 09:09

waqar ahmed