【发布时间】:2011-01-06 09:09:35
【问题描述】:
我试图设置一个 ruby 控制台 应用程序来在我的 Twitter 状态上发布“Hello world”,但我无法通过授权。
我看过一些关于基本身份验证的教程,使用基本身份验证创建应用程序很容易。但不幸的是,基本身份验证已被 twitter 禁用,所以现在我们必须使用 OAuth,这似乎要困难得多。
是否有关于如何编写控制台应用程序以使用 OAuth 将“Hello World”发布到 Twitter 的教程?还是不能在控制台应用程序中使用 OAuth?
谢谢
编辑
对于 Ruby:https://github.com/jnunemaker/twitter(由 Thiago Silveira 提供)
对于 C#:http://p2p.wrox.com/content/articles/twitter-development-using-oauth-authenticate-against-twitter-api-walkthroughs(由 Casey 提供)
实际上,使用 Ruby 制作“hello world”控制台应用程序非常简单。正如 Thiago Silveira 所提到的,有一个 Ruby twitter gem https://github.com/jnunemaker/twitter,它为任何 Ruby 程序员开始使用 twitter 提供了很好的文档。
注意事项
时钟问题可能会阻止您成功使用 OAuth。
我在问这个问题之前使用了 Ruby twitter gem,但无法让 OAuth 正常工作,这就是我首先问这个问题的原因。实际问题是 OAuth 需要时间戳才能获取请求令牌,但我的 时钟未与互联网时钟同步。 (见这里:http://blainegarrett.com/2009/07/14/failed-to-validate-oauth-signature-and-token-on-twitter-oauth-check-your-cloc/)所以在我同步了我的时钟后,twitter gem 工作得很好。
【问题讨论】:
-
关于 Ruby,您可以使用 twitter gem:github.com/jnunemaker/twitter
-
我试过那个宝石。但它在这条线上失败了
Twitter.update("I'm tweeting from the Twitter Ruby Gem!"),说POST https://api.twitter.com/1/statuses/update.json: 401 Unauthorized: Timestamp out of bounds (Twitter::Unauthorized) -
@Thiago Silveira 现在它对我有用。谢谢。我发现我最初的问题是时钟没有与互联网同步。 blainegarrett.com/2009/07/14/…