欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

微信授权登录

程序员文章站 2024-02-18 13:40:10
...

-(void)Clbtn{
[[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_WechatSession currentViewController:nil completion:^(id result, NSError *error) {
if (error) {

    } else {
        UMSocialUserInfoResponse *resp = result;
        // 授权信息
        NSLog(@"Wechat uid: %@", resp.uid);
        NSLog(@"Wechat openid: %@", resp.openid);
        NSLog(@"Wechat unionid: %@", resp.unionId);
        NSLog(@"Wechat accessToken: %@", resp.accessToken);
        NSLog(@"Wechat refreshToken: %@", resp.refreshToken);
        NSLog(@"Wechat expiration: %@", resp.expiration);
        // 用户信息
        NSLog(@"Wechat name: %@", resp.name);
        NSLog(@"Wechat iconurl: %@", resp.iconurl);
        NSLog(@"Wechat gender: %@", resp.unionGender);
        // 第三方平台SDK源数据
        NSLog(@"Wechat originalResponse: %@", resp.originalResponse);
    }
}];

}
-(void)btn{
//显示分享面板
[UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {

    [self shareWebPageToPlatformType:platformType];
    
    // 根据获取的platformType确定所选平台进行下一步操作
}];

}

  • (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType
    {
    //创建分享消息对象
    UMSocialMessageObject messageObject = [UMSocialMessageObject messageObject];
    //创建网页内容对象
    NSString
    thumbURL = @“https://mobile.umeng.com/images/pic/home/social/img-1.png”;
    UMShareWebpageObject shareObject = [UMShareWebpageObject shareObjectWithTitle:@“欢迎使用【友盟+】社会化组件U-Share” descr:@“欢迎使用【友盟+】社会化组件U-Share,SDK包最小,集成成本最低,助力您的产品开发、运营与推广!” thumImage:thumbURL];
    //设置网页地址
    shareObject.webpageUrl = @“http://mobile.umeng.com/social”;
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError error) {
    if (error) {
    UMSocialLogInfo(@"************Share fail with error %@
    *******",error);
    }else{
    if ([data isKindOfClass:[UMSocialShareResponse class]]) {
    UMSocialShareResponse *resp = data;
    //分享结果消息
    UMSocialLogInfo(@“response message is %@”,resp.message);
    //第三方原始返回的数据
    UMSocialLogInfo(@“response originalResponse data is %@”,resp.originalResponse);
    }else{
    UMSocialLogInfo(@“response data is %@”,data);
    }
    }
    }];
    }
相关标签: 微信授权登录