zoukankan      html  css  js  c++  java
  • 微信登陆的回调设置

     

    //#pragma mark - 微信登入回调

    //-(void) onReq:(BaseReq*)req

    //{

    //    if([req isKindOfClass:[GetMessageFromWXReq class]])

    //    {

    //        GetMessageFromWXReq *temp = (GetMessageFromWXReq *)req;

    //        

    //        // 微信请求App提供内容, 需要app提供内容后使用sendRsp返回

    //        NSString *strTitle = [NSString stringWithFormat:@"微信请求App提供内容"];

    //        NSString *strMsg = [NSString stringWithFormat:@"openID: %@", temp.openID];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        alert.tag = 1000;

    //        [alert show];

    //    }

    //    else if([req isKindOfClass:[ShowMessageFromWXReq class]])

    //    {

    //        ShowMessageFromWXReq* temp = (ShowMessageFromWXReq*)req;

    //        WXMediaMessage *msg = temp.message;

    //        

    //        //显示微信传过来的内容

    //        WXAppExtendObject *obj = msg.mediaObject;

    //        

    //        NSString *strTitle = [NSString stringWithFormat:@"微信请求App显示内容"];

    //        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, 标题:%@ 内容:%@ 附带信息:%@ 缩略图:%u bytes 附加消息:%@ ", temp.openID, msg.title, msg.description, obj.extInfo, msg.thumbData.length, msg.messageExt];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    //    else if([req isKindOfClass:[LaunchFromWXReq class]])

    //    {

    //        LaunchFromWXReq *temp = (LaunchFromWXReq *)req;

    //        WXMediaMessage *msg = temp.message;

    //        

    //        //从微信启动App

    //        NSString *strTitle = [NSString stringWithFormat:@"从微信启动"];

    //        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, messageExt:%@", temp.openID, msg.messageExt];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    //}

    //

    //-(void) onResp:(BaseResp*)resp

    //{

    //    if([resp isKindOfClass:[SendMessageToWXResp class]])

    //    {

    //        NSString *strTitle = [NSString stringWithFormat:@"发送媒体消息结果"];

    //        NSString *strMsg = [NSString stringWithFormat:@"errcode:%d", resp.errCode];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    //    else if([resp isKindOfClass:[SendAuthResp class]])

    //    {

    //        SendAuthResp *temp = (SendAuthResp*)resp;

    //        

    //        NSString *strTitle = [NSString stringWithFormat:@"Auth结果"];

    //        NSString *strMsg = [NSString stringWithFormat:@"code:%@,state:%@,errcode:%d",temp.code, temp.state, temp.errCode];

    //        

    //        //用户同意

    //        if (0 == temp.errCode) {

    //            //开始请求

    //            [WXDataServer requestURL:@"https://api.weixin.qq.com/sns/oauth2/access_token"

    //                          httpMethod:@"GET"

    //                              params:[@{@"appid":kWXAppID,@"secret":kWXAppSecret,@"code":temp.code,@"grant_type":@"authorization_code"} mutableCopy]

    //                                file:nil

    //                             success:^(id data) {

    //                                 NSLog(@"-------------------------success");

    //                                 NSString *str = (NSString *)data;

    //                                 NSLog(@"-------------------------str:%@",str);

    //                             }

    //                                fail:^(NSError *error) {

    //                                    NSLog(@"-------------------------filed");

    //                                    NSLog(@"111111111:%@",error);

    //                                    NSLog(@"-------------------------filed");

    //                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"请求失败,检查网络" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];

    //                                    [alertView show];

    //                                }

    //             ];

    //        }

    //    }

    //    else if ([resp isKindOfClass:[AddCardToWXCardPackageResp class]])

    //    {

    //        AddCardToWXCardPackageResp* temp = (AddCardToWXCardPackageResp*)resp;

    //        NSMutableString* cardStr = [[NSMutableString alloc] init];

    //        for (WXCardItem* cardItem in temp.cardAry) {

    //            [cardStr appendString:[NSString stringWithFormat:@"cardid:%@ cardext:%@ cardstate:%lu ",cardItem.cardId,cardItem.extMsg,cardItem.cardState]];

    //        }

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"add card resp" message:cardStr delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    //}

     

    #pragma mark - 微信登入回调

    -(void) onReq:(BaseReq*)req

    {

        NSLog(@"----------");

    //    if([req isKindOfClass:[GetMessageFromWXReq class]])

    //    {

    //        GetMessageFromWXReq *temp = (GetMessageFromWXReq *)req;

    //        

    //        // 微信请求App提供内容, 需要app提供内容后使用sendRsp返回

    //        NSString *strTitle = [NSString stringWithFormat:@"微信请求App提供内容"];

    //        NSString *strMsg = [NSString stringWithFormat:@"openID: %@", temp.openID];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        alert.tag = 1000;

    //        [alert show];

    //    }

    //    else if([req isKindOfClass:[ShowMessageFromWXReq class]])

    //    {

    //        ShowMessageFromWXReq* temp = (ShowMessageFromWXReq*)req;

    //        WXMediaMessage *msg = temp.message;

    //        

    //        //显示微信传过来的内容

    //        WXAppExtendObject *obj = msg.mediaObject;

    //        

    //        NSString *strTitle = [NSString stringWithFormat:@"微信请求App显示内容"];

    //        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, 标题:%@ 内容:%@ 附带信息:%@ 缩略图:%u bytes 附加消息:%@ ", temp.openID, msg.title, msg.description, obj.extInfo, msg.thumbData.length, msg.messageExt];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    //    else if([req isKindOfClass:[LaunchFromWXReq class]])

    //    {

    //        LaunchFromWXReq *temp = (LaunchFromWXReq *)req;

    //        WXMediaMessage *msg = temp.message;

    //        

    //        //从微信启动App

    //        NSString *strTitle = [NSString stringWithFormat:@"从微信启动"];

    //        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, messageExt:%@", temp.openID, msg.messageExt];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    }

    //

    -(void) onResp:(BaseResp*)resp

    {

        NSLog(@"----------onResp");

    //    if([resp isKindOfClass:[SendMessageToWXResp class]])

    //    {

    //        NSString *strTitle = [NSString stringWithFormat:@"发送媒体消息结果"];

    //        NSString *strMsg = [NSString stringWithFormat:@"errcode:%d", resp.errCode];

    //        

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    //    else if([resp isKindOfClass:[SendAuthResp class]])

    //    {

    //        SendAuthResp *temp = (SendAuthResp*)resp;

    //        

    //        NSString *strTitle = [NSString stringWithFormat:@"Auth结果"];

    //        NSString *strMsg = [NSString stringWithFormat:@"code:%@,state:%@,errcode:%d",temp.code, temp.state, temp.errCode];

    //        

    //        //用户同意

    //        if (0 == temp.errCode) {

    //            //开始请求

    //            [WXDataServer requestURL:@"https://api.weixin.qq.com/sns/oauth2/access_token"

    //                          httpMethod:@"GET"

    //                              params:[@{@"appid":kWXAppID,@"secret":kWXAppSecret,@"code":temp.code,@"grant_type":@"authorization_code"} mutableCopy]

    //                                file:nil

    //                             success:^(id data) {

    //                                 NSLog(@"-------------------------success");

    //                                 NSString *str = (NSString *)data;

    //                                 NSLog(@"-------------------------str:%@",str);

    //                             }

    //                                fail:^(NSError *error) {

    //                                    NSLog(@"-------------------------filed");

    //                                    NSLog(@"111111111:%@",error);

    //                                    NSLog(@"-------------------------filed");

    //                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"请求失败,检查网络" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];

    //                                    [alertView show];

    //                                }

    //             ];

    //        }

    //    }

    //    else if ([resp isKindOfClass:[AddCardToWXCardPackageResp class]])

    //    {

    //        AddCardToWXCardPackageResp* temp = (AddCardToWXCardPackageResp*)resp;

    //        NSMutableString* cardStr = [[NSMutableString alloc] init];

    //        for (WXCardItem* cardItem in temp.cardAry) {

    //            [cardStr appendString:[NSString stringWithFormat:@"cardid:%@ cardext:%@ cardstate:%lu ",cardItem.cardId,cardItem.extMsg,cardItem.cardState]];

    //        }

    //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"add card resp" message:cardStr delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    //        [alert show];

    //    }

    }

  • 相关阅读:
    JSR303实现数据校验案例
    maven安装和相关配置
    mybatis分页插件使用案例
    分页查询案例
    ssm整合相关配置
    配置文件没有按照maven约定存放解决方法
    git常用命令和基本使用
    mybatis配置二级缓存
    Angular第三方UI组件库------ionic
    Angular路由知识点
  • 原文地址:https://www.cnblogs.com/wskgjmhh/p/4610369.html
Copyright © 2011-2022 走看看