在 iOS 中使用 twitter 登录用户......使用什么? [英] Login user with twitter in iOS... what to use?

查看:30
本文介绍了在 iOS 中使用 twitter 登录用户......使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前有人问过类似的问题(我已经阅读了大部分),但我还没有找到好的答案.

I know similar questions have been asked before (I've read most of them), but I haven't found a good answer yet.

我需要从 iOS 使用 Twitter 登录/注册用户.我有这个网站,我已经在做这件事 (www.Meer.li),现在我也需要在应用程序中做这件事.

I need to login/signup users with twitter from iOS. I have this website where I am already doing that (www.Meer.li) and now I need to do it in the app as well.

我知道我可以在 iOS 设备上访问 Twitter 用户名并查看它是否在我的应用程序的数据库中,但是当用户未注册 www.Meer.li 时我该如何处理还没有?

I know I can get access to the twitter username on the iOS-device and see if it is in the database of my app, but how do I handle things when the user isn't signed up to www.Meer.li yet?

对不起,如果这是一个微不足道的问题,但我有点困惑我应该使用 iOS 社交框架还是使用一些 OAuth 库(Restkit 等).

Sorry if it is a trivial question, but I'm a bit confused wether I should use the iOS Social framework or use some OAuth library (Restkit, etc).

希望有人能指导我找到答案甚至是例子!

Hope someone can guide me in the direction of an answer or maybe even an example!

需要澄清:

非常感谢指导.似乎有道理.可以肯定的是,这就是我理解的步骤:

Thanks a lot for the guidance. Seems reasonable. Just to be sure, this is how I understand the steps to be:

1:用户使用推特按钮点击登录

1: User clicks on login with twitter button

2:我们获取用户的 Twitter 帐户并询问他想使用哪个帐户

2: We get users twitter accounts and ask him which one he wants to use

3:我们向 twitter 发送请求,其中包含您自己的应用程序的密钥和秘密以及用户的 twitter 信息

3: We send off a request to twitter with the key and secret for your own app and the users twitter info

4:如果收到良好的响应,将收到的信息发送到您的 web 应用程序上创建用户的方法,并从那里向 Twitter 请求剩余的用户信息

4: If good response is received back, send the received info to the method on your webapp that creates users and make a request from there to twitter for the remaining user info

5:让用户玩得开心

这样对吗?为什么以前没有人很好地记录此流程?听起来应该很容易做到.

Is that about right? Why hasn't anyone documented this flow very well before? Sounds like a thing that should be very easy to do.

推荐答案

注意: iOS 5+ 会为您处理所有 OAuth 和繁重的工作,因此只有在您需要时才使用此答案支持较旧的操作系统版本.

Note: iOS 5+ takes care of all of the OAuth and heavy lifting for you so only use this answer if you're supporting older OS versions.

现在有一个很好的 WWDC 2012 演示,介绍了如何在 Twitter.framework 已弃用的情况下执行此操作.登录以查看此链接:http://adcdownload.apple.com/wwdc_20120facebook_twitter_and_twitter_session_pdfs/session_306__integrating_with_facebook_twitter_and_sina_weibo.pdf".pdf

There is a good WWDC 2012 presentation about how to do this now that the Twitter.framework is deprecated. Login to see this link: http://adcdownload.apple.com/wwdc_2012/wwdc_2012_session_pdfs/session_306__integrating_with_facebook_twitter_and_sina_weibo.pdf

我只需要自己做.

到目前为止,我找到的最佳答案是 Sean Cook 的 TWReverseAuthExample.(我分叉了他的 github 项目,然后将其归结为我在 TWReverseAuthSubModule 中作为基于 ARC 的应用程序的子模块所需的基本要素,去掉示例项目等,因为我知道我可以在原始的 github 源代码中返回它.)

by far the best answer i found was Sean Cook's TWReverseAuthExample . (i forked his github project, then boiled it down to the essentials i needed as a submodule for my ARC-based apps in TWReverseAuthSubModule, stripping out the example project, et al, since i knew i could get back to it at the original github source.)

基本上,如果你按照这个例子,它会按照概述的步骤进行Twitter API 网页.

basically, if you follow the example, it follows through on the steps outlined on the Twitter API web pages.

最后,您需要做的是创建与肖恩示例非常相似的代码.

in the end, what you need to do is create code that looks pretty much like sean's example.

网络上还有其他我最初开始使用的资源,它们允许我使用 twitter 登录",这些资源可以在嵌套的 UIWebView 中进行授权,甚至可以去 safari,然后通过专用应用程序 URL 方案.如果您需要进行 iOS 5.x 之前的工作,这些可能会有所帮助.

there were other resources on the net which i had originally started using which allowed me to "login using twitter" in ways that would do the authorization in a nested UIWebView or even going out to safari and then coming back into the app via dedicated app URL scheme. and these might be helpful if you need to do pre-iOS 5.x stuff.

但上面的示例充分利用了原生 iOS 推特支持,并且也适用于 iOS 6.

but the example above takes the best advantage of native iOS twitter support, and works also with iOS 6 .

这篇关于在 iOS 中使用 twitter 登录用户......使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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