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.
I've seen some tutorials on basic auth开发者_JS百科entication, 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.
Is there a tutorial on how to write a console application to post "Hello World" to Twitter using OAuth? Or is it not possible to use OAuth in a console application?
Thanks
Edit
for Ruby: https://github.com/jnunemaker/twitter (provided by Thiago Silveira)
for C#: http://p2p.wrox.com/content/articles/twitter-development-using-oauth-authenticate-against-twitter-api-walkthroughs (provided by Casey)
Actually it's quite easy to an "hello world" console app using Ruby. 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.
The Caveat
The clock issue might prevented you from successfully using 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. 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. (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.
I've used the following successfully in the past. Scroll down and there is an example of doing this from a C# console application.
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.
精彩评论