没有社交框架的 Twitter 登录 [英] Twitter login without social framework

查看:34
本文介绍了没有社交框架的 Twitter 登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 ios 应用中实现 twitter 登录.我不想使用社交框架.我已经尝试了所有方法来登录 twitter,但不幸的是这不起作用.主要是我面临其中的回调 url 问题.你能帮我吗.

I am trying to implement twitter login in my ios app. I do not want to use social frame work. I have tried all ways to twitter login but unfortunately this not working. Mainly i am facing the callback url issue in it. Can you please guys help me.

我也试过这个网址

http://codegerms.com/login-with-twitter-example-with-ios-tutorial-using-oauth/

但主要是我面临回调问题.任何人都可以请推荐其他插件.

but mainly i am facing the callback issue. Can any one please suggest other plugin.

推荐答案

要从 Twitter 获取用户信息,您可以使用 OAuth.io 的 iOS SDK:https://github.com/oauth-io/oauth-ios

To get the user's information from Twitter, you can use OAuth.io's iOS SDK: https://github.com/oauth-io/oauth-ios

https://oauth.io 上创建帐户并添加 Twitter 作为提供商后,您将能够很容易地获取用户的信息.您只需按照以下步骤操作:

After having created an account on https://oauth.io, and added Twitter as a provider, you'll be able to get the user's info quite easily. You just need to follow these steps:

通过可可豆荚:

$ pod install "OAuth.io"

手动:

只需获取 OAuthiOS.framework 文件 在这里并像安装任何其他框架一样安装它.

Just get the OAuthiOS.framework file here and install it like any other framework.

在您的 ViewController 中添加 #import .

Add #import <OAuthiOS/OAuthiOS.h> in your ViewController.

@interface MyViewController : UIViewController<OAuthIODelegate>
//[...]
@end

4 在 ViewController 中初始化并启动身份验证弹出窗口:

4 Initialize and launch an authentication popup in the ViewController:

OAuthIOModal *oauthioModal = [[OAuthIOModal alloc] initWithKey:@"your_app_public_key" delegate:self];
[oauthioModal showWithProvider:@"twitter"];

5 实现以下委托方法来获取请求对象,这让您可以检索用户的信息,感谢 me 方法:

5 Implement the following delegate method to get a Request Object, that lets you retrieve the user's information, thanks to the me method:

- (void)didReceiveOAuthIOResponse:(OAuthIORequest *)request
{
    [_request me:nil success:^(NSDictionary *output, NSString *body, NSHTTPURLResponse 
    *httpResponse)
     {
         NSLog(@"name: %@", [output objectForKey:@"name"]);
     }];
}

要获取有关 iOS SDK 的更多信息,请随时查看此处的指南:

To get more information about the iOS SDK, feel free to check out the guide here:

https://oauth.io/getting-started?ios&None

您也可以在此处遵循基于 git 的教程:

You can also follow a git based tutorial here:

https://oauth.io/docs/tutorials/client/ios

并在此处找到 SDK 的参考文档:

And find the reference documentation of the SDK here:

https://oauth.io/docs/api-reference/client/ios

请注意,OAuth.io 还在 oauthd 项目中开源了它们的核心(查看这里的 repo:https://github.com/oauth-io/oauthd)

Note that OAuth.io also open sourced their core in the oauthd project (check out the repo here: https://github.com/oauth-io/oauthd)

希望这有帮助:)

这篇关于没有社交框架的 Twitter 登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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