好吧,这并不短,我无法仅用几行甚至显示一些代码来告诉您整个过程,但我会尽力为您提供指导。
1. 认证
首先,大多数 Twitter API 调用都需要身份验证(使用您的消费者密钥)。要进行身份验证,您必须请求 twitter oAuth TOKEN(这就是请求和授权 URL 的原因)。如果没有这些令牌,您将无法发出需要授权的 API 调用请求。
身份验证是通过 oAuth 进行的(很多平台使用 oAuth 进行身份验证,因此请熟悉这一点):https://dev.twitter.com/docs/auth/using-oauth https://dev.twitter.com/docs/auth/using-oauth
您尚未指定需要集成的内容,但这里解释一下您需要如何通过需要集成的内容进行身份验证:https://dev.twitter.com/docs/auth/obtaining-access-tokens https://dev.twitter.com/docs/auth/obtaining-access-tokens
如果您想使用用户数据,则需要此身份验证:https://dev.twitter.com/docs/auth/implementing-sign-twitter https://dev.twitter.com/docs/auth/implementing-sign-twitter
基本流程是:
- 使用您的消费者密钥,您可以向 Twitter 请求令牌
- 您将把您的应用程序重定向到 Twitter,以便用户通过 Twitter 登录
- Twitter 会将秘密令牌扔回您的 CALLBACK URL 以进行 API 调用
再次强调,这是一个简短的内容,上面提到的文档中有详细说明
2. 调用API
Twitter 通过他们的 REST API 提供了很多服务,文档很棒,你可以轻松找到你需要使用的内容:
https://dev.twitter.com/docs/api/1.1 https://dev.twitter.com/docs/api/1.1
基本上每个服务方法都有自己的 url 和调用所需的参数。当您提供它时,您将收到一个 (JSON) 响应。
为了帮助调试,他们提供了一个令人惊叹的 API 浏览器,可以提供很多帮助:
https://dev.twitter.com/console https://dev.twitter.com/console
3. Twitter 库
最后,我们有一些为 .NET 编写的 twitter 库:
https://dev.twitter.com/docs/twitter-libraries https://dev.twitter.com/docs/twitter-libraries
https://github.com/danielcrenna/tweetsharp https://github.com/danielcrenna/tweetsharp
http://linqtotwitter.codeplex.com/ http://linqtotwitter.codeplex.com/
Twitterizer 是一个很棒的库,但他们似乎已经停止支持:https://github.com/Twitterizer/Twitterizer https://github.com/Twitterizer/Twitterizer
Twitter 上的一些 Twitterizer 示例:https://dev.twitter.com/docs/auth/oauth/single-user-with-examples#csharp https://dev.twitter.com/docs/auth/oauth/single-user-with-examples#csharp
如果有人知道好的,请编辑这篇文章。
4. 最重要的
如果您有任何疑问,请不要害怕在这里研究、阅读、阅读和阅读:https://dev.twitter.com/docs https://dev.twitter.com/docs