- (void)loginAction:(UIButton *)button{
if (button.tag == 1) {
UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToQQ];
snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess)
{ UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:UMShareToQQ];
NSLog(@"QQSnsInformation++++++++ is %@",response.data);
[self.user setNick_name:snsAccount.userName];
[self.user setIconURL:snsAccount.iconURL];
[self.user setMobile:[NSString stringWithFormat:@"%@%@",@"02?",snsAccount.usid]];
[self.user setPassword:[snsAccount.usid substringWithRange:NSMakeRange(0, 6)]];
if([snsAccount.usid isEqualToString:@""]){
[DWDProgressHUD showText:@"QQ登录失败"];
}else {
[self setROOTController];
}
[[UMSocialDataService defaultDataService]requestSnsInformation: UMShareToQQ completion:^(UMSocialResponseEntity*response){
NSLog(@"QQSnsInformation is %@",response.data);
}];
}
});
}else if (button.tag == 2){
UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:UMShareToSina];
[self.user setNick_name:snsAccount.userName];
[self.user setIconURL:snsAccount.iconURL];
[self.user setMobile:[NSString stringWithFormat:@"%@%@",@"01?",snsAccount.openId]];
[self.user setPassword:[snsAccount.openId substringWithRange:NSMakeRange(0, 6)]];
if([snsAccount.openId isEqualToString:@""]){
[DWDProgressHUD showText:@"微信登录失败"];
}else {
[self setROOTController];
}
NSLog(@"新浪SnsInformation++++++++ is %@",response.data);
NSLog(@"username is %@, uid is %@, token is %@ url is %@",snsAccount.userName,snsAccount.usid,snsAccount.accessToken,snsAccount.iconURL);
[[UMSocialDataService defaultDataService] requestSnsInformation:UMShareToSina completion:^(UMSocialResponseEntity*response){
NSLog(@"新浪SnsInformation is %@",response.data);
NSLog(@"性别++++++%@",[response.data objectForKey:@"gender"]);
if([[response.data objectForKey:@"gender"] isEqualToString:@"m"]){
[self.user setSex:@"男"];
}else if([[response.data objectForKey:@"gender"] isEqualToString:@"f"]){
[self.user setSex:@"女"];
}
}];
}
});
}else if (button.tag == 3){
UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatSession];
snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
UMSocialAccountEntity *snsAccount = [[UMSocialAccountManagersocialAccountDictionary]valueForKey:UMShareToWechatSession];
NSLog(@"微信SnsInformation+++++++ is %@",response.data);
[self.user setNick_name:snsAccount.userName];
[self.user setIconURL:snsAccount.iconURL];
[self.user setMobile:[NSString stringWithFormat:@"%@%@",@"01?",snsAccount.openId]];
[self.user setPassword:[snsAccount.openId substringWithRange:NSMakeRange(0, 6)]];
if([snsAccount.openId isEqualToString:@""]){
[DWDProgressHUD showText:@"微信登录失败"];
}else {
[self setROOTController];
}
NSLog(@"username is %@, uid is %@, token is %@ url is %@",snsAccount.userName,snsAccount.openId,snsAccount.accessToken,snsAccount.iconURL);
}
[[UMSocialDataService defaultDataService] requestSnsInformation:UMShareToWechatSession completion:^(UMSocialResponseEntity *response){
NSLog(@"微信SnsInformation is %@",response.data);
}
[UMSocialData openLog:YES];
[UMSocialData setAppKey:@"5959a46865b6d62f26000cf1"];
//微信
[UMSocialWechatHandler setWXAppId:@"wx60552e9ae57417b6" appSecret:@"cc8ebfdc921b7f02c3bc7a66877e55d1"url:@"http://www.umeng.com/social"];
//注册QQ分享
[UMSocialQQHandler setQQWithAppId:@"1106260337" appKey:@"8hd7J2HhJMvUJJ3Q"url:@"http://www.umeng.com/social"];
//新浪微博
[UMSocialSinaSSOHandler openNewSinaSSOWithAppKey:@"2828395878"
secret:@"66593a0fd05ea29e9e58700651c5d0f1"
RedirectURL:@"https://api.weibo.com/oauth2/default.html"];
}];
});
}
}