获取带有特定主题标签的所有推文
我一直在尝试 Twitter API,因为我想在特殊页面上显示一些推文列表。
在这些列表中,有一个列表包含包含特定主题标签的所有推文(例如 #test)
但是我找不到如何以 XML 或 JSON(最好是后者)的形式获取该列表,有人知道如何获取吗?如果可以在 TweetSharp 中完成也可以
I've been experimenting with the Twitter API because I want to display a few lists of tweets on a special page.
Among those lists is a list with all tweets containing a specific hashtag (e.g. #test)
However I cannot find how to get that list in either XML or JSON (preferably the latter), does anyone know how? It is also fine if it can be done in TweetSharp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您只需获取
http://search.twitter.com/search.json?q=%23test
即可获取包含 JSON 格式的#test
的推文列表,其中 < code>%23test 是#test
URL 编码。我对 TweetSharp 不熟悉,但我猜一定有一个
search
命令,您可以使用它来搜索#test
,然后自己将生成的推文转换为 JSON 。You can simply fetch
http://search.twitter.com/search.json?q=%23test
to get a list of tweets containing#test
in JSON, where%23test
is#test
URL encoded.I'm not familiar with TweetSharp, but I guess there must be a
search
command that you can use to search for#test
, and then transform the resulting tweets into JSON yourself.首先使用github安装TweetSharp
https://github.com/danielcrenna/tweetsharp
这是进行搜索的代码
如果您有超过一页的结果,您可以可以设置循环并调用每个页面
First install TweetSharp using github
https://github.com/danielcrenna/tweetsharp
Here is the code to do a search
If you have more then one page results you can setup a loop and call each page
自过去几个月以来,API 似乎发生了变化。这是更新后的代码:
It seems like there is a change in the API since last few months. Here is the updated code:
您可以通过此网址访问您的推文搜索。但你必须使用 OAuth 协议。
https://api.twitter.com/1.1/search/tweets。 json?q=%40twitterapi
u access with this url for your tweet searchs. But u have to use OAuth protocols.
https://api.twitter.com/1.1/search/tweets.json?q=%40twitterapi
我也遇到了同样的问题。这是我的模糊解决方案。享受编程。
每当获取/获取所需数量的推文时,它就会退出该函数。
}
I struggled with the same problem. Here is my vague solution . Enjoy Programming.
It will get out of the function whenever your required number of tweets are acquired/fetched.
}