Does the Twitter API allow filtering by username AND hashtag?

让人想犯罪 __ 提交于 2019-12-22 10:35:14

问题


Can I get all the tweets of a particular user, in which a particular hashtag is used?

I could just get the past 100 tweets then filter them on my end, but it would be much more convenient if Twitter could do the filtering on their end.

Is this possible?


回答1:


Twitter's Advanced Search lets you construct the query you desire. Unfortunately, search results only seem to be for tweets posted within the past 24 hours or so right now; might just be a temporary limitation, not sure.

In any case, your request URL might look something like this (note the JSON and Atom types):

http://search.twitter.com/search?q=%23HASHTAG+from:USERNAME http://search.twitter.com/search.json?q=%23HASHTAG+from:USERNAME http://search.twitter.com/search.atom?q=%23HASHTAG+from:USERNAME

But with the current timeframe limitation, it's not very practical.




回答2:


I am reading the twitter documentation and they say right now it will include only 6-9 days of tweets. Link https://dev.twitter.com/docs/using-search




回答3:


To do this search against v1.1 of Twitter's API (which requires OAuth), you'd issue a GET request to the a URL structured like:

https://api.twitter.com/1.1/search/tweets.json?q=from:whitehouse+#sotu

See their Search API's "How to build a query" section. You'll be constrained to tweets over the last 7 days, though.



来源:https://stackoverflow.com/questions/3540618/does-the-twitter-api-allow-filtering-by-username-and-hashtag

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