我正在开发一个需要访问 Twitter 的移动应用程序。有大量关于将 Twitter API 与网络应用程序结合使用的文档,但我很难找到正确的流程或任何使用台式机和移动应用程序的带外/PIN 码模式的示例。
谁能给我指出一个链接或一些代码示例(最好是 C# 语言)来告诉我如何从桌面或移动应用程序使用 Twitter API?
谢谢。
最佳答案
在 http://dev.twitter.com/pages/auth 底部的词汇表部分有一些 OOB 流的描述。
out of band mode - Instead of providing a URL-based callback when acquiring a request token, "oob" is supplied. Once the user has given Twitter their account credentials, they are presented with a screen containing a PIN code and are asked to enter this code into the application. The application then sends this PIN as an oauth_verifier to the access token step to complete the exchange.
与正常的网络流程相比,这在实践中意味着什么:
- 在步骤 (A) 中,您的应用通过打开 OAuth 流程的浏览器窗口来启动流程,但发送的请求参数是
oauth_callback=oob
而不是回调 URL - 步骤 (C) 以 Twitter 显示包含用户 PIN 的授权结果页面结束(而不是使用正常的网络流程回调您的应用)
- 步骤 (D) 要求用户将 Twitter 身份验证页面中的 PIN 复制/输入到您的应用程序中(您的应用程序显然需要某种“等待授权代码...”屏幕:)
- 第 (E) 步,您的应用将用户输入的 PIN 在
oauth_verifier
参数中发送回 Twitter,以获取访问 token 。
尝试 DotNetOpenAuth 中的 OAuthConsumerWpf 示例 http://www.dotnetopenauth.net/获取您应该能够修改的 OAuth 消费者代码的示例。
关于c# - Twitter API - OOB 流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4974275/