三方登录友盟 sso授权集成微信、QQ、微博方法,及各个平台注册

- (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 socialAccountDictionaryvalueForKey: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(06)]];

                if([snsAccount.usid isEqualToString:@""]){

                    [DWDProgressHUD showText:@"QQ登录失败"];

                }else {

                    [self setROOTController];

                }

                [[UMSocialDataService defaultDataService]requestSnsInformationUMShareToQQ  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 socialAccountDictionaryvalueForKey: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(06)]];

                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 defaultDataServicerequestSnsInformation: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(06)]];

                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 defaultDataServicerequestSnsInformation: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"];



            }];

        });

    }

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值