验证新的Twitter的API 1.1 [英] Authentication for new Twitter API 1.1

查看:271
本文介绍了验证新的Twitter的API 1.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要显示一个公共页面上的随机用户的追随者数量及以下(用户/ show.json )(不需要验证)的应用程序。
随着Twitter的API 1.0因为不需要为请求验证这是很容易的。随着新的Twitter的API 1.1是没有更多的可能,所以我需要进行身份验证请求(通过的OAuth )。

I have an application that needs to display number of followers and following (users/show.json) for a random user on a public page (authentication is not required). With the Twitter API 1.0 it was quite easy as authentication is not needed for the request. With the new Twitter API 1.1 is no more possible, so I need to authenticate the request (via OAuth).

是否有可能只是身份验证应用程序,而不是用户呢?
我的意思是:我能避免要求用户登录,并只与应用程序键/验证的秘密?或每次我需要创建用户凭据也一个道理,创造回调,等等?

Is it possible only "authenticate" the application and not the user too? I mean: can I avoid to ask user to login and only authenticate with application key/secret? Or everytime I need to create a token with user credentials too, creating callback, etc.?

推荐答案

是的,这是可能的!如果您的应用程序不需要做这样的事情后状态或代表用户发送直接消息,你应该能够用一个硬codeD集微博的 OAuth的凭据,而不是要求用户进行身份验证。

Yes, it is possible! If your application doesn't need to do things like post statuses or send direct messages on behalf of a user, you should be able to retrieve all of a user's public information with a single hardcoded set of Twitter OAuth credentials, and not require the user to authenticate.


  • 登录Twitter和去开发人员仪表板在 https://dev.twitter.com/apps

  • 注册一个新的应用;在注册应用程序后,查看应用程序的详细信息。你会看到一个OAuth的工具选项卡,在这里你会发现所有该应用程序相关的OAuth值:主要消费品,消费者的秘密,访问令牌和访问令牌密钥

  • 使用这些凭据,你就可以做出请求到新的Twitter API。

如果你不舒服直接使用Twitter的API,也有一些很好的API封装在那里为各种语言 - 除其他外,Temboo SDK,它会给你打电话的各种方法code片段(而且也给你一个地方安全地存储你的Twitter的凭据,所以你不需要他们烤到你的应用程序)。

If you're not comfortable using the Twitter API directly, there are a number of good API wrappers out there for various languages -- among others, the Temboo SDK, which will give you code snippets for calling various methods (and also gives you a place to securely store your Twitter credentials, so you don't need to bake them into your application).

看看:

(全面披露:我在工作Temboo)

(Full disclosure: I work at Temboo.)

这篇关于验证新的Twitter的API 1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆