获取第三方登录(相关信息 新浪微博&微信&QQ)&&登录和分享接口功能

QQ 登录 获取信息  需要有一个代理 回调

-(void)getUserInfoResponse:(APIResponse *)response
{
 //   NSLog(@"respons:%@",response.jsonResponse);
     
    self.name.text = [response.jsonResponse objectForKey:@"nickname"];
}

使用回调之前需要设置一句代码

[_tencentOAuth getUserInfo];

连接  点击打开链接


微信登录 获取信息

授权成功后 需要请求该接口地址如下

https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID

会返回该信息

 /*                  
                    {                  
                    city = Haidian;                  
                    country = CN;                  
                    headimgurl = "http://wx.qlogo.cn/mmopen/FrdAUicrPIibcpGzxuD0kjfnvc2klwzQ62a1brlWq1sjNfWREia6W8Cf8kNCbErowsSUcGSIltXTqrhQgPEibYakpl5EokGMibMPU/0";                  
                    language = "zh_CN";                  
                    nickname = "xxx";                  
                    openid = oyAaTjsDx7pl4xxxxxxx;                  
                    privilege =     (                  
                    );                  
                    province = Beijing;                  
                    sex = 1;                  
                    unionid = oyAaTjsxxxxxxQ42O3xxxxxxs;                  
                    }                  
                */                                    
                 

 NSString *url =[NSString stringWithFormat:@"https://api.weixin.qq.com/sns/userinfo?access_token=%@&openid=%@",self.access_token.text,self.openid.text];            
     
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{          
        NSURL *zoneUrl = [NSURL URLWithString:url];          
        NSString *zoneStr = [NSString stringWithContentsOfURL:zoneUrl encoding:NSUTF8StringEncoding error:nil];          
        NSData *data = [zoneStr dataUsingEncoding:NSUTF8StringEncoding];          
        dispatch_async(dispatch_get_main_queue(), ^{              
            if (data) {                  
                NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];                  
                self.nickname.text = [dic objectForKey:@"nickname"];              
                self.wxHeadImg.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[dic objectForKey:@"headimgurl"]]]];
            }          
        });        
    });  


连接  点击打开链接


微博登录 获取信息

微博在授权成功后 会调用一个回调用法 你需要在回调方法那里  写一个接口调用如下

http://open.weibo.com/wiki/2/users/show



案例地址: https://api.weibo.com/2/users/show.json?source=%@&access_token=%@&uid=%@

返回的基本信息

"screen_name": "zaku",
    "name": "zaku",
    "province": "11",
    "city": "5",
    "location": "北京 朝阳区",
    "description": "人生五十年,乃如梦如幻;有生斯有死,壮士复何憾。",
    "url": "http://blog.sina.com.cn/zaku",
    "profile_image_url": "http://tp1.sinaimg.cn/1404376560/50/0/1",
    "domain": "zaku",
    "gender": "m",


GitHub 地址: https://github.com/lingochamp/Diplomat


GitHub 地址:https://github.com/DevSonw/HoDiplomat



 

你可能感兴趣的:(iOS)