Twitter search (atom) API - exclude retweets

别来无恙 提交于 2019-11-29 18:10:05

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/7400656/twitter-search-atom-api-exclude-retweets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!