首页 > 解决方案 > 按标签搜索 Twitter Api

问题描述

我到底如何使用 Twitter API?网上的一切似乎都过时了,而且不起作用。我在开发者门户上创建了一个 twitter 应用程序并获得了我的访问令牌等。我现在该怎么办?我正在尝试使用 JQuery 发出 ajax 获取请求。但是我该怎么做?他们的文档完全是垃圾。

标签: javascripttwitter

解决方案


请参考文档

它建议您可以使用网址的地方

https://api.twitter.com/1.1/search/tweets.json?q=%23superbowl&result_type=recent

获取带有superbowl主题标签的最新推文。

请注意,#该网址中的 已编码为%23. 您可以在此处找到这些编码的参考。

从文档中,您可以执行以下不同的搜索操作:

Operator                            Finds Tweets...
watching now                        containing both “watching” and “now”. This is the default operator.
“happy hour”                        containing the exact phrase “happy hour”.
love OR hate                        containing either “love” or “hate” (or both).
beer -root                          containing “beer” but not “root”.
#haiku                              containing the hashtag “haiku”.
from:interior                       sent from Twitter account “interior”.
list:NASA/astronauts-in-space-now   sent from a Twitter account in the NASA list astronauts-in-space-now
to:NASA                             a Tweet authored in reply to Twitter account “NASA”.
@NASA                               mentioning Twitter account “NASA”.
politics filter:safe                containing “politics” with Tweets marked as potentially sensitive removed.
puppy filter:media                  containing “puppy” and an image or video.
puppy -filter:retweets              containing “puppy”, filtering out retweets
puppy filter:native_video           containing “puppy” and an uploaded video, Amplify video, Periscope, or Vine.
puppy filter:periscope              containing “puppy” and a Periscope video URL.
puppy filter:vine                   containing “puppy” and a Vine.
puppy filter:images                 containing “puppy” and links identified as photos, including third parties such as Instagram.
puppy filter:twimg                  containing “puppy” and a pic.twitter.com link representing one or more photos.
hilarious filter:links              containing “hilarious” and linking to URL.
puppy url:amazon                    containing “puppy” and a URL with the word “amazon” anywhere within it.
superhero since:2015-12-21          containing “superhero” and sent since date “2015-12-21” (year-month-day).
puppy until:2015-12-21              containing “puppy” and sent before the date “2015-12-21”.
movie -scary :)                     containing “movie”, but not “scary”, and with a positive attitude.
flight :(                           containing “flight” and with a negative attitude.
traffic ?                           containing “traffic” and asking a question.

推荐阅读