/// <summary> /// 授权并获取用户信息 /// </summary> private void GetAuthWithUserInfo() { UMSocialManager.DefaultManager().GetUserInfoWithPlatform(UMSocialPlatformType.WechatSession, new UIViewController(), (result, error) => { if (error != null) { } else { UMSocialUserInfoResponse resp = (UMSocialUserInfoResponse)result; // 授权信息 Console.WriteLine(@"Wechat uid: " + resp.Uid); Console.WriteLine(@"Wechat openid: " + resp.Openid); Console.WriteLine(@"Wechat accessToken:" + resp.AccessToken); Console.WriteLine(@"Wechat refreshToken:" + resp.RefreshToken); Console.WriteLine(@"Wechat expiration: " + resp.Expiration); // 用户信息 Console.WriteLine(@"Wechat name: " + resp.Name); Console.WriteLine(@"Wechat iconurl: " + resp.Iconurl); Console.WriteLine(@"Wechat gender: " + resp.Gender); // 第三方平台SDK源数据 Console.WriteLine(@"Wechat originalResponse: " + resp.OriginalResponse); } }); }
private void ShareVideo() { UMSocialMessageObject messageObject = UMSocialMessageObject.MessageObject; UMShareVideoObject shareObject = UMShareVideoObject.ShareObjectWithTitle("分享标题", "分享内容描述", new UIImage()); // 设置网页播放地址 shareObject.VideoUrl = "http://"; //shareObject.VideoStreamUrl = @"这里设置视频数据流地址(如果有的话,而且也要看所分享的平台支不支持)"; messageObject.ShareObject = shareObject; // 调用分享接口 UMSocialManager.DefaultManager().ShareToPlatform(UMSocialPlatformType.Sina, messageObject, new UIViewController(), (data, error) => { if (error != null) { Console.WriteLine(error); } else { Console.WriteLine(data); } }); }
private void ShareMusic() { // 创建分享消息对象 UMSocialMessageObject messageObject = UMSocialMessageObject.MessageObject; // 创建音乐内容对象 UMShareMusicObject shareObject = UMShareMusicObject.ShareObjectWithTitle("分享标题", "分享内容描述", new UIImage()); shareObject.MusicUrl = "http://"; //shareObject.MusicDataUrl = ""; // 这里设置音乐数据流地址(如果有且分享平台支持) messageObject.ShareObject = shareObject; // 调用分享接口 UMSocialManager.DefaultManager().ShareToPlatform(UMSocialPlatformType.Sina, messageObject, new UIViewController(), (data, error) => { if (error != null) { Console.WriteLine(error); } else { Console.WriteLine(data); } }); }
private void ShareWebPage() { UMSocialMessageObject messageObject = UMSocialMessageObject.MessageObject; UMShareWebpageObject shareObject = UMShareWebpageObject.ShareObjectWithTitle("分享标题", "分享内容描述", new UIImage()); // 设置网页 shareObject.WebpageUrl = "http://"; // 分享消息对象设置分享内容对象 messageObject.ShareObject = shareObject; // 调用分享接口 UMSocialManager.DefaultManager().ShareToPlatform(UMSocialPlatformType.Sina, messageObject, new UIViewController(), (data, error) => { if (error != null) { Console.WriteLine(error); } else { Console.WriteLine(data); } }); }
// 分享图文(新浪支持,微信、QQ 仅支持图片或文本分享) private void ShareImageAndText() { UMSocialMessageObject messageObject = UMSocialMessageObject.MessageObject; // 设置文本 messageObject.Text = "分享文本内容"; // 创建图片内容对象 UMShareImageObject shareObject = new UMShareImageObject(); // 如果有缩略图,则设置缩略图 shareObject.ThumbImage = new UIImage(); shareObject.ShareImage = new NSString("https://"); messageObject.ShareObject = shareObject; UMSocialManager.DefaultManager().ShareToPlatform(UMSocialPlatformType.Sina, messageObject, new UIViewController(), (data, error) => { if (error != null) { Console.WriteLine(error); } else { Console.WriteLine(data); } }); }
private void ShareText() { UMSocialMessageObject messageObject = UMSocialMessageObject.MessageObject; messageObject.Text = "分享文本内容"; UMSocialManager.DefaultManager().ShareToPlatform(UMSocialPlatformType.Sina, messageObject, new UIViewController(), (data, error) => { if (error != null) { Console.WriteLine(error); } else { Console.WriteLine(data); } }); }
/// <summary> /// 授权仅获取 Token 和 UID /// </summary> private void GetAuth() { UMSocialManager.DefaultManager().AuthWithPlatform(UMSocialPlatformType.WechatSession, null, (result, error) => { if (error != null) { } else { UMSocialAuthResponse resp = (UMSocialAuthResponse)result; // 授权信息 Console.WriteLine(@"Wechat uid: " + resp.Uid); Console.WriteLine(@"Wechat openid: " + resp.Openid); Console.WriteLine(@"Wechat accessToken: " + resp.AccessToken); Console.WriteLine(@"Wechat refreshToken: " + resp.RefreshToken); Console.WriteLine(@"Wechat expiration: " + resp.Expiration); // 第三方平台SDK源数据 Console.WriteLine(@"Wechat originalResponse: %@", resp.OriginalResponse); } }); }