zoukankan      html  css  js  c++  java
  • QQ简单登录

    1.下载QQ官方API文档,导入对应的包

    2.在Info->URL Types文件添加

    Identifier:tencent  URL Schemes:tencent+应用appkey(去腾讯后台注册)

    3.Appdelegate文件

    #pragma mark --- QQLogin-----
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
        return [TencentOAuth HandleOpenURL:url];
    }
    
    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
        return [TencentOAuth HandleOpenURL:url];
    }

    4.对应的viewController文件

    #import <TencentOpenAPI/TencentOAuth.h>
    
    @interface LoginController ()<TencentSessionDelegate>
    {
        UIView *_loginView;
        TencentOAuth *_tencentLogin;
    }
    //QQ
    -(void)qqLogin:(UIButton *)btn
    {
        _tencentLogin=[[TencentOAuth alloc]initWithAppId:@"222222" andDelegate:self];
         NSArray *permissions = [NSArray arrayWithObjects:@"get_user_info", @"get_simple_userinfo", @"add_t", nil];
        [_tencentLogin authorize:permissions localAppId:@"222222" inSafari:YES];
    }
    
    #pragma mark----QQLogin----
    -(void)tencentDidLogin
    {
        NSString *infoUrl=[NSString stringWithFormat:@"https://graph.qq.com/user/get_simple_userinfo?access_token=%@&oauth_consumer_key=%@&openid=%@",_tencentLogin.accessToken,@"222222",_tencentLogin.openId];
        //NSLog(@"%@",infoUrl);
        [NetWorkManage getUserInfoByQQWithUrl:infoUrl whenSuccess:^(id responseData) {
            id result = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil];
            if ([result isKindOfClass:[NSDictionary class]]) {
                NSDictionary *userDic = result;
                //
                NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
                NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:userDic[@"figureurl_qq_2"]]];
                [userDefault setObject:userDic[@"nickname"] forKey:@"NickName"];
                [userDefault setObject:data forKey:@"UserImg"];
                [userDefault synchronize];
                self.showUserData();
                [self.navigationController popViewControllerAnimated:YES];
            }
        } Failure:^(NSError *error) {
            
        }];
    }
    -(void)tencentDidNotNetWork
    {
        
    }
    -(void)tencentDidNotLogin:(BOOL)cancelled
    {
        
    }
  • 相关阅读:
    idea websitehttp://www.youyur.com/
    chromium project相关页面
    WebKit Remote Debugging
    天兰尾货
    GitCookbook from google chromium
    ocr识别
    Google发布Chrome官方扩展DOM Snitch 可发现网页代码漏洞
    WebKit2 High Level Document ¶
    Phantom JS: an alternative to Selenium
    Python Extension
  • 原文地址:https://www.cnblogs.com/liaods/p/4805369.html
Copyright © 2011-2022 走看看