C# 控制台应用程序 Streaming API 1.1 + Oauth [英] C# console application Streaming API 1.1 + Oauth

查看:48
本文介绍了C# 控制台应用程序 Streaming API 1.1 + Oauth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 swhitley 的 Twitter Stream Client 使用用户名和密码通过 Twitter Streaming API 下载推文.它使用的是 https://stream.twitter.com/1.1/statuses/filter.json.

I am using swhitley's Twitter Stream Client to download tweets via Twitter Streaming API with username and password. It was using https://stream.twitter.com/1.1/statuses/filter.json.

我修改了代码以添加 OAuth,但出现 400 错误.任何人都可以向我提供代码或将我引导到一个开源项目.或者只是给我一些有关如何解决问题的提示.

I modified the code to add OAuth, but I am getting a 400 error. Can anyone pls provide me code or direct me to an opensource project. Or just give me some tips on how to fix the issue.

推荐答案

如果您的 API 有问题,您可以尝试使用 Tweetinvi

If you are having some troubles with your API you can try using Tweetinvi

该 API 由我和另一位开发人员开发,目的是使用 Streaming API.

The API has been developed by myself and another developer in the goal of using the Streaming API.

它非常易于使用,您可以在解决方案 (Examplinvi) 中找到示例.

It is pretty easy to use and you can find examples in the solution (Examplinvi).

基本上,您只需定义一个方法,该方法将为从 API 收到的每条推文调用.我们已经能够使用此 API(存储在 MySQL 数据库中)每天处理 350 万条推文.

Basically, you just have to define a method that will be called foreach of the Tweet received from the API. We have been able to process 3.5 millions tweets a day with this API (storing in MySQL Database).

// Creating the stream and specifying the delegate
SimpleStream myStream = new SimpleStream("https://stream.twitter.com/1.1/statuses/sample.json");
// Create the credentials
IToken token = new Token("userKey", "userSecret", "consumerKey", "consumerSecret");
// Starting the stream by specifying credentials thanks to the Token
myStream.StartStream(token, x => Console.WriteLine(x.Text));

如果您需要任何帮助,请随时问我.

If you need any help, feel free to ask me.

这篇关于C# 控制台应用程序 Streaming API 1.1 + Oauth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆