Twitter search (atom) API - exclude retweets
Asked Answered
M

2

10

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?

Measure answered 13/9, 2011 at 10:51 Comment(2)
I used now q=ConatiningWord -RT but is this reliable?Measure
No, you might want to look in to regex.Tenant
F
17

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

Fledgling answered 16/10, 2011 at 6:28 Comment(1)
This seems to have the same effect as "-rt". I tried a few search strings containing RT and with +exclude:retweets they never return anything.Downrange
W
6

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 :)

Warehouseman answered 20/12, 2011 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.