在ASP.NET Twitter的API集成 [英] Twitter API Integration in ASP.NET
问题描述
目前我正在MVC4.5剃刀,
我曾尝试Twitter的API在我的应用程序,但没有运气集成。你能帮我如何Twitter的API在我的应用程序集成。我已创建Twitter的API,详细介绍如下
OAuth的设置
访问级别只读有关应用程序的权限模型
消费键 - [ConsumerKey]
消费者的秘密 - [ConsumerSecret]
请求令牌
网址 https://api.twitter.com/oauth/request_token 授权
网址 https://api.twitter.com/oauth/authorize 访问令牌
网址 https://api.twitter.com/oauth/access_token 回调
网址 http://www.opalevents.org/
块引用>解决方案好吧,这不算短,我不能告诉你,整个过程只用几行字,甚至显示出一些code,但我会尽量给你方向。
1。验证
首先,大部分Twitter的API调用需要身份验证(使用消费密钥)。要验证您有权要求Twitter的OAuth凭证(这就是为什么请求和授权URL)。如果没有这些标记,你是不是能够做出对需要授权的API调用请求。
身份验证通过OAuth发(很多plataforms的使用OAuth认证,所以与熟悉):
https://dev.twitter.com/docs/auth/using-oauth您还没有指定您需要整合,但在这里解释你如何需要通过您需要整合什么来验证的内容:
https://dev.twitter.com/docs/auth/obtaining-access-tokens如果您要使用用户数据的工作,你需要这个验证:的https: //dev.twitter.com/docs/auth/implementing-sign-twitter
其基本流程是:
- 与您的消费键您请求的令牌给Twitter
- 您会重定向您的应用程序到Twitter,用户通过Twitter登录
- Twitter将丢回给你的回调URL的秘密令牌进行API调用
再次,这是一个简单的,这是所有在详细文档上述上面
2。进行API调用
微博通过自己的REST API提供了很多服务,文档是伟大的,你可以找到你需要轻松地使用什么:
https://dev.twitter.com/docs/api/1.1
基本上每个服务方法有其自己的URL和用于进行呼叫所需的参数。而当你提供给它,您会收到一个(JSON)响应。
要帮助调试,他们提供了一个惊人的API资源管理器中,这有很大帮助:
https://dev.twitter.com/console
3。 Twitter的图书馆
最后,我们必须为.NET编写的微博一些库:
https://dev.twitter.com/docs/twitter-libraries
https://github.com/danielcrenna/tweetsharp
HTTP://linqtotwitter.$c$cplex.com/
Twitterizer是一个了不起的图书馆,但似乎他们已经停止支持:
https://github.com/Twitterizer/Twitterizer在Twitter的一些Twitterizer例如:
https://dev.twitter.com/docs/auth / OAuth的/单用户与 - 【举例】#CSHARP如果有人知道好的,请编辑这个职位。
4。最重要的是
如果你有一些问题,不要害怕研究,读,读,读这里:的https: //dev.twitter.com/docs
Currently I am working MVC4.5 with razor, I have try to integrate Twitter API in My Application but no luck. Could you please help me how to integrate Twitter API in my Application. I have create twitter API which details following
OAuth settings
Access level Read-only About the application permission model
Consumer key - [ConsumerKey]
Consumer secret - [ConsumerSecret]
Request token URL https://api.twitter.com/oauth/request_token Authorize URL https://api.twitter.com/oauth/authorize Access token URL https://api.twitter.com/oauth/access_token Callback URL http://www.opalevents.org/
解决方案Okay, this isn't short and I can't tell you the whole process just with a few lines or even showing some code, but I'll try to give you the directions.
1. Authentication
First of all , most of Twitter API calls need to authentication (using your consumer keys). To authenticate you have to request twitter oAuth TOKENs (that's why request and authorize URL). Without these tokens, you aren't able to make requests for API calls that require authorization.
Authentication is made via oAuth (a lot of plataforms uses oAuth to authenticate, so familiarize with that): https://dev.twitter.com/docs/auth/using-oauth
You have not specified what you need to integrate, but here explain how you need to authenticate by what you need to integrate: https://dev.twitter.com/docs/auth/obtaining-access-tokens
if you want to work with user data, you need this authentication: https://dev.twitter.com/docs/auth/implementing-sign-twitter
The basic flow is:
- With your consumer keys you request a token to twitter
- You'll redirect your application to twitter, to user sign in via twitter
- Twitter will throw back to your CALLBACK URL the secret token to make API calls
again, this is a brief, that's all detailed at mentioned docs above
2. Making API calls
Twitter provide a lot of services through their REST API, the documentation is great, and you can find what you need to use easily:
https://dev.twitter.com/docs/api/1.1
Basically each service method have its own url and required parameters for making a call. And when you provide it, you'll receive a (JSON) response.
To help debug, they provide an amazing API explorer, that helps A LOT:
https://dev.twitter.com/console
3. Twitter Libraries
Finally we have some library for twitter written for .NET:
https://dev.twitter.com/docs/twitter-libraries
https://github.com/danielcrenna/tweetsharp
http://linqtotwitter.codeplex.com/
Twitterizer was an amazing library, but seems they have stopped support: https://github.com/Twitterizer/Twitterizer
some Twitterizer example at Twitter: https://dev.twitter.com/docs/auth/oauth/single-user-with-examples#csharp
if someone know good ones, please edit this post.
4. Most important
And if you have some question, don't be afraid to research, read , read and read here: https://dev.twitter.com/docs
这篇关于在ASP.NET Twitter的API集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!