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

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

问题描述

我之前已经问过类似的问题(我已经阅读了大部分内容),但我还没有找到一个好的答案。



我需要使用来自iOS的Twitter登录/注册用户。我有这个网站,我已经在那里(www.Meer.li),现在我也需要在应用程序中这样做。



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



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



希望有人可以指导我回答问题或者甚至是一个例子!



要澄清:



非常感谢您的指导。似乎合理。只是为了确定,这就是我理解的步骤:



1:用户点击使用Twitter按钮登录



2:我们得到用户的Twitter帐户,并问他想要使用哪个



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



4:如果收到良好的回复,请将收到的信息发送到您的webapp上创建用户的方法,并从那里有Twitter剩余的用户信息



5:让用户玩得开心



那是对的吗?为什么之前没有人记录过这种流程?听起来应该很容易做到。

解决方案

注意: iOS 5+需要如果你支持旧的操作系统版本,请只关注所有的OAuth和繁重的工作。



有一个很好的WWDC 2012演示文稿,关于如何现在不推荐使用Twitter.framework。登录以查看此链接: http://adcdownload.apple.com/wwdc_2012/wwdc_2012_session_pdfs/session_306__integrating_with_facebook_twitter_and_sina_weibo .pdf






我必须自己做这件事。



到目前为止,我找到的最佳答案是 Sean Cook的TWReverseAuthExample 。 (我分了他的github项目,然后把它归结为我需要的基本要素,作为基于ARC的应用程序的子模块,在 TWReverseAuthSubModule ,删除了示例项目,等等,因为我知道我可以在原来的github源代码回复它。)



基本上,如果你关注例如,它按照在Twitter API网页上列出的步骤进行操作



最后,你需要做的是创建看起来非常像肖恩的例子的代码。



<网上还有其他资源我最初开始使用它允许我以使用twitter登录的方式在嵌套的UIWebView中进行授权,甚至可以去野生动物园,然后通过专用回到应用程序应用URL方案。如果你需要做iOS 5.x之前的东西,这些可能会有所帮助。



但上面的例子充分利用了原生的iOS twitter支持,并且也有效iOS 6。


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

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.

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?

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!

To be clarified:

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

1: User clicks on login with twitter button

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

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

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: Let user have fun

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.

解决方案

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.

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


i just had to do this myself.

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.)

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.

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.

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

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

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