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.