简体   繁体   English

Ruby或C#:如何编写控制台应用程序以向Twitter发布状态

[英]Ruby or C#: how to write a console application to post a status to Twitter

I was trying to set up a ruby console application to post "Hello world" on my Twitter status, but I couldn't pass the authorization. 我试图设置一个ruby 控制台应用程序在我的Twitter状态上发布“Hello world”,但我无法通过授权。

I've seen some tutorials on basic authentication, and it was easy to use basic authentication to create an app. 我已经看过一些关于基本身份验证的教程,并且很容易使用基本身份验证来创建应用程序。 But unfortunately basic authentication has been disabled by twitter, so now we have to use OAuth, which seems much more difficult. 但遗憾的是,Twitter已禁用基本身份验证,因此现在我们必须使用OAuth,这似乎要困难得多。

Is there a tutorial on how to write a console application to post "Hello World" to Twitter using OAuth? 是否有关于如何编写控制台应用程序以使用OAuth将“Hello World”发布到Twitter的教程? Or is it not possible to use OAuth in a console application? 或者是否无法在控制台应用程序中使用OAuth?

Thanks 谢谢

Edit 编辑

for Ruby: https://github.com/jnunemaker/twitter (provided by Thiago Silveira) 对于Ruby: https//github.com/jnunemaker/twitter (由Thiago Silveira提供)

for C#: http://p2p.wrox.com/content/articles/twitter-development-using-oauth-authenticate-against-twitter-api-walkthroughs (provided by Casey) 对于C#: http//p2p.wrox.com/content/articles/twitter-development-using-oauth-authenticate-against-twitter-api-walkthroughs (由Casey提供)

Actually it's quite easy to an "hello world" console app using Ruby. 实际上,使用Ruby的“hello world”控制台应用程序非常容易。 As mentioned by Thiago Silveira, there's a Ruby twitter gem https://github.com/jnunemaker/twitter , which has pretty good documentation for any Ruby programmer to get started on using twitter. 正如Thiago Silveira所提到的,有一个Ruby twitter gem https://github.com/jnunemaker/twitter ,它有很好的文档可供任何Ruby程序员开始使用twitter。

The Caveat 警告

The clock issue might prevented you from successfully using OAuth. 时钟问题可能会阻止您成功使用OAuth。

I used Ruby twitter gem before asking this question and couldn't get the OAuth working correct, which is why I asked this question in the first place. 我在问这个问题之前使用过Ruby twitter gem,但是无法让OAuth正常工作,这就是我首先提出这个问题的原因。 The actual problem is that OAuth needs a timestamp in order to get the request token but my clock wasn't synchronized with internet clock. 实际问题是OAuth需要时间戳才能获取请求令牌,但我的时钟与互联网时钟不同步 (see here: http://blainegarrett.com/2009/07/14/failed-to-validate-oauth-signature-and-token-on-twitter-oauth-check-your-cloc/ ) So after I synced my clock, twitter gem works perfectly well. (见这里: http//blainegarrett.com/2009/07/14/failed-to-validate-oauth-signature-and-token-on-twitter-oauth-check-your-cloc/ )所以在我同步后时钟,twitter gem非常适合。

I've used the following successfully in the past. 我过去成功使用过以下内容。 Scroll down and there is an example of doing this from a C# console application. 向下滚动,有一个从C#控制台应用程序执行此操作的示例。

http://p2p.wrox.com/content/articles/twitter-development-using-oauth-authenticate-against-twitter-api-walkthroughs http://p2p.wrox.com/content/articles/twitter-development-using-oauth-authenticate-against-twitter-api-walkthroughs

Should say that I am not sure if there have been any changes since that walk through was published. 应该说我不确定自那次演出以来是否有任何变化已经发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM