IOS QQ Third party login Implementation _ios

Source: Internet
Author: User

This example for you to share the iOS QQ Third-party login Implementation code for your reference, the specific contents are as follows

First, preparatory work

1, to QQ open platform (http://connect.qq.com/) registered as a developer, apply for Appkey,
2, in the URL types add QQ AppID, its format is: "Tencent" + AppID such as tencent1104463316

Second, configure APPDELEGATE.M

1, import <TencentOpenAPI/QQApiInterface.h> and <TencentOpenAPI/TencentOAuth.h> two header files
2. Configuration function:

-(BOOL) Application: (UIApplication *) application Handleopenurl: (nsurl *) URL 
{return 
  [Tencentoauth Handleopenurl:url]; 
} 
 
-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (id) annotation 
{return 
  [Tencentoauth Handleopenurl:url]; 

Set up code in the login interface

1, import #import <TencentOpenAPI/TencentOAuth.h>
2, comply with the agreement:<tencentsessiondelegate>
3, trigger the login method to write code:

-(void) Qqlogin 
{ 
  nsarray* permissions = [Nsarray arraywithobjects: 
              kopen_permission_get_user_info, 
              Kopen_permission_get_simple_user_info, 
              kopen_permission_add_album, 
              nil Nil]; 
  [Self.tencentoauth authorize:permissions]; 
} 

4, get the user information

-(void) Tencentdidlogin 
{ 
  [Self.tencentoauth getuserinfo]; 
} 
[OBJC] View plain copy on code that is derived from my Code slice
-(void) Getuserinforesponse: (apiresponse*) response 
{ 
  NSLog (@ "GetUserInfo =%@", response.jsonresponse); 
  NSLog (@ "getuserinfo.nickname =%@", [response.jsonresponseobjectforkey:@ "nickname"]); 
  nsstring* alertmessage = [nsstringstringwithformat:@ "%@", Response.jsonresponse]; 
  nsstring* Headerpath = [response.jsonresponseobjectforkey:@ "figureurl_qq_2"]; 
  nsstring* name = [response.jsonresponseobjectforkey:@ "nickname"]; 

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.