/// <summary> /// 移动 /// </summary> /// <param name="seasonId"></param> /// <param name="seasonType"></param> /// <returns></returns> public async Task <ReturnModel> MoveStatus(int seasonId, int status) { try { var url = "https://api.bilibili.com/pgc/app/follow/status/update"; var body = $"access_key={ApiHelper.access_key}&appkey={ApiHelper.AndroidKey.Appkey}&build={ApiHelper.build}&platform=android&season_id={seasonId}&status={status}&ts={ApiHelper.GetTimeSpan}"; body += "&sign=" + ApiHelper.GetSign(body); string results = await WebClientClass.PostResults(new Uri(url), body); JObject json = JObject.Parse(results); if ((int)json["code"] == 0) { return(new ReturnModel() { success = true }); } else { return(new ReturnModel() { success = false, message = json["message"].ToString() }); } } catch (Exception ex) { return(HandelError(ex)); } }
private async void btn_Delete_Click(object sender, RoutedEventArgs e) { try { foreach (GetFavouriteBoxsVideoModel item in User_ListView_FavouriteVideo.SelectedItems) { //string results = await WebClientClass.PostResults(new Uri("http://space.bilibili.com/ajax/fav/mdel"), string.Format("fid={0}&aids={1}", fid, item.aid)); Uri ReUri = new Uri("http://api.bilibili.com/x/v2/fav/video/del"); string content = string.Format( "access_key={0}&aid={2}&appkey={1}&build=520001&fid={3}&mobi_app=android&platform=android&re_src=90&ts={4}", ApiHelper.AccessKey, ApiHelper.AndroidKey.Appkey, item.aid, fid, ApiHelper.TimeStamp2 ); content += "&sign=" + ApiHelper.GetSign(content); string result = await WebClientClass.PostResults(ReUri, content ); JObject json = JObject.Parse(result); if ((int)json["code"] == 0) { User_ListView_FavouriteVideo.Items.Remove(item); } else { Utils.ShowMessageToast("取消收藏失败", 2000); } } } catch (Exception ex) { await new MessageDialog("删除失败\r\n" + ex.Message).ShowAsync(); } }
private async void CreateCollectFolder() { try { var isOpen = 0; if (cb_isopen.IsChecked.Value) { isOpen = 1; } string url = "https://api.bilibili.com/audio/music-service-c/collections"; string content = string.Format("access_key={0}&appkey={1}&build=5250000&is_open={5}&mid={2}&mobi_app=android&platform=android&title={3}&ts={4}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, ApiHelper.GetUserId(), txt_title.Text, ApiHelper.GetTimeSpan, isOpen); content += "&sign=" + ApiHelper.GetSign(url); var re = await WebClientClass.PostResults(new Uri(url), content); JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { cd_Create.Hide(); LoadCollections(); } else { Utils.ShowMessageToast("创建收藏夹失败"); } } catch (Exception) { Utils.ShowMessageToast("创建失败"); } }
private async void gv_like_ItemClick(object sender, ItemClickEventArgs e) { try { var info = e.ClickedItem as LikeTagsModel; string results = await WebClientClass.PostResults(new Uri("http://api.bilibili.com/x/tag/subscribe/add"), "jsonp=jsonp&tag_id=" + info.tag_id, "http://www.bilibili.com/"); JObject obj = JObject.Parse(results); if ((int)obj["code"] == 0) { Utils.ShowMessageToast("订阅成功", 3000); MyTagModel m = new MyTagModel() { tag_id = info.tag_id, name = info.tag_name }; gv_like.Items.Remove(e.ClickedItem); gv.Items.Add(m); } else { Utils.ShowMessageToast(obj["message"].ToString(), 3000); } } catch (Exception) { Utils.ShowMessageToast("订阅失败", 3000); } }
private async void ls_collections_ItemClick(object sender, ItemClickEventArgs e) { var item = e.ClickedItem as SongCollectionsModel; try { string url = "https://api.bilibili.com/audio/music-service-c/collections/songs/" + _songId; string content = string.Format("access_key={0}&appkey={1}&build=5250000&collection_id_list={2}&mid={3}&mobi_app=android&platform=android&song_id={4}&ts={5}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, item.collection_id, ApiHelper.GetUserId(), _songId, ApiHelper.GetTimeSpan); content += "&sign=" + ApiHelper.GetSign(url); var re = await WebClientClass.PostResults(new Uri(url), content); JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { btn_Collect.Flyout.Hide(); Utils.ShowMessageToast("收藏成功"); } else { Utils.ShowMessageToast(obj["msg"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("收藏失败"); } }
/// <summary> /// 订阅频道 /// </summary> /// <param name="channel_id">频道ID</param> /// <returns></returns> public async Task <ReturnModel> FollowChannel(int channel_id) { try { string url = "https://app.bilibili.com/x/channel/add"; string data = $"access_key={ApiHelper.access_key}&appkey={ApiHelper.AndroidKey.Appkey}&build={ApiHelper.build}&channel_id={channel_id}&mobi_app=android&platform=android&ts={ApiHelper.GetTimeSpan}"; data += "&sign=" + ApiHelper.GetSign(data); var results = await WebClientClass.PostResults(new Uri(url), data); var model = results.ToDynamicJObject(); if (model.code == 0) { return(new ReturnModel() { success = true, message = "" }); } else { return(new ReturnModel() { success = false, message = model.message }); } } catch (Exception ex) { return(HandelError(ex)); } }
private async void SendMessage(string rid) { try { string url = "https://api.vc.bilibili.com/web_im/v1/web_im/send_msg"; // url += "&sign=" + ApiHelper.GetSign(url); string results = await WebClientClass.PostResults(new Uri(url), string.Format("platform=pc&msg%5Bsender_uid%5D={0}&msg%5Breceiver_id%5D={1}&msg%5Breceiver_type%5D=1&msg%5Bmsg_type%5D=1&msg%5Bcontent%5D=%7B%22content%22%3A%22{2}%22%7D&msg%5Btimestamp%5D={3}&captcha={4}", ApiHelper.GetUserId(), rid, Uri.EscapeDataString(txt_Content.Text), ApiHelper.GetTimeSpan, captcha_key)); JObject o = JObject.Parse(results); //ChatModel m = JsonConvert.DeserializeObject<ChatModel>(results); if ((int)o["code"] != 0) { Utils.ShowMessageToast("发送失败," + o["message"].ToString(), 2000); } else { txt_Content.Text = ""; } sc.ChangeView(null, sc.ExtentHeight, null); //RaisePropertChanged("messages"); } catch (Exception ex) { Utils.ShowMessageToast("发送失败\r\n" + ex.Message, 2000); //throw; } }
private async void Btn_Like_Click(object sender, RoutedEventArgs e) { if (!ApiHelper.IsLogin() && !await Utils.ShowLoginDialog()) { Utils.ShowMessageToast("请登录后再执行操作"); return; } try { var body = $"access_key={ApiHelper.access_key}&aid={_aid}&appkey={ApiHelper.AndroidKey.Appkey}&build={ApiHelper.build}&platform=android&dislike=0&like=0&ts={ApiHelper.GetTimeSpan}"; body += "&sign=" + ApiHelper.GetSign(body); var results = await WebClientClass.PostResults(new Uri("https://app.bilibili.com/x/v2/view/like"), body); var obj = JObject.Parse(results); if (obj["code"].ToInt32() == 0) { Utils.ShowMessageToast("点赞完成"); } else { Utils.ShowMessageToast(obj["message"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("点赞失败了啊"); } }
private static async Task <string> EncryptedPassword(string passWord) { string base64String; try { HttpBaseProtocolFilter httpBaseProtocolFilter = new HttpBaseProtocolFilter(); httpBaseProtocolFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.Expired); httpBaseProtocolFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.Untrusted); Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient(httpBaseProtocolFilter); string url = "https://passport.bilibili.com/api/oauth2/getKey"; string content = $"appkey={ApiHelper._appKey}&mobi_app=android&platform=android&ts={ApiHelper.GetTimeSpan}"; content += "&sign=" + ApiHelper.GetSign(content); string stringAsync = await WebClientClass.PostResults(new Uri(url), content); JObject jObjects = JObject.Parse(stringAsync); string str = jObjects["data"]["hash"].ToString(); string str1 = jObjects["data"]["key"].ToString(); string str2 = string.Concat(str, passWord); string str3 = Regex.Match(str1, "BEGIN PUBLIC KEY-----(?<key>[\\s\\S]+)-----END PUBLIC KEY").Groups["key"].Value.Trim(); byte[] numArray = Convert.FromBase64String(str3); AsymmetricKeyAlgorithmProvider asymmetricKeyAlgorithmProvider = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaPkcs1); CryptographicKey cryptographicKey = asymmetricKeyAlgorithmProvider.ImportPublicKey(WindowsRuntimeBufferExtensions.AsBuffer(numArray), 0); IBuffer buffer = CryptographicEngine.Encrypt(cryptographicKey, WindowsRuntimeBufferExtensions.AsBuffer(Encoding.UTF8.GetBytes(str2)), null); base64String = Convert.ToBase64String(WindowsRuntimeBufferExtensions.ToArray(buffer)); } catch (Exception) { base64String = passWord; } return(base64String); }
public async Task <ReturnModel> UnFollow(int uid) { try { string url = "https://api.bilibili.com/x/relation/modify"; string data = $"access_key={ApiHelper.access_key}&act=2&appkey={ApiHelper._appKey}&build={ApiHelper.build}&fid={uid}&mobi_app=android&platform=android&ts={ApiHelper.GetTimeSpan}&re_src=31"; data += "&sign=" + ApiHelper.GetSign(data); string result = await WebClientClass.PostResults(new Uri(url), data); JObject jb = JObject.Parse(result); if ((int)jb["code"] == 0) { return(new ReturnModel() { success = true, message = "" }); } else { return(new ReturnModel() { success = false, message = "取消关注失败" }); } } catch (Exception ex) { return(HandelError(ex)); } }
public async void TouBi(int num) { if (ApiHelper.IsLogin()) { try { WebClientClass wc = new WebClientClass(); Uri ReUri = new Uri("https://app.bilibili.com/x/v2/view/coin/add"); string QuStr = string.Format("access_key={0}&aid={1}&appkey={2}&build=540000&from=7&mid={3}&platform=android&&multiply={4}&ts={5}", ApiHelper.access_key, _aid, ApiHelper.AndroidKey.Appkey, ApiHelper.GetUserId(), num, ApiHelper.GetTimeSpan); QuStr += "&sign=" + ApiHelper.GetSign(QuStr); string result = await WebClientClass.PostResults(ReUri, QuStr); JObject jObject = JObject.Parse(result); if (Convert.ToInt32(jObject["code"].ToString()) == 0) { Utils.ShowMessageToast("投币成功!", 3000); } else { Utils.ShowMessageToast(jObject["message"].ToString(), 3000); } } catch (Exception ex) { Utils.ShowMessageToast("投币时发生错误\r\n" + ex.Message, 3000); } } else { Utils.ShowMessageToast("请先登录!", 3000); } }
private async void DeleteCollect() { try { var cid = (cb_favbox.SelectedItem as SongCollectionsModel).collection_id.ToString(); var songs = ""; foreach (MusicHomeSongModel item in list_songs.SelectedItems) { songs += item.id + ","; } string url = "https://api.bilibili.com/audio/music-service-c/collections/collectionfresh"; string content = string.Format("access_key={0}&appkey={1}&build=5250000&collectionId={2}&mid={3}&mobi_app=android&platform=android&songIds={4}&ts={5}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, cid, ApiHelper.GetUserId(), Uri.EscapeDataString(songs), ApiHelper.GetTimeSpan); content += "&sign=" + ApiHelper.GetSign(url); var re = await WebClientClass.PostResults(new Uri(url), content); JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { LoadSongs(cid); } else { Utils.ShowMessageToast(obj["msg"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("删除收藏失败"); } }
private async void SendMessage(string rid) { try { wc = new WebClientClass(); string url = "http://message.bilibili.com/api/msg/send.msg.do"; // url += "&sign=" + ApiHelper.GetSign_Android(url); string results = await wc.PostResults(new Uri(url), string.Format("access_key={0}&actionKey=appkey&appkey={1}&build=422000&data_type=1&mobi_app=android&platform=android&rid={2}&ts={3}000&msg={4}", ApiHelper.access_key, ApiHelper._appKey_Android, rid, ApiHelper.GetTimeSpen, Uri.EscapeDataString(txt_Content.Text))); JObject o = JObject.Parse(results); //ChatModel m = JsonConvert.DeserializeObject<ChatModel>(results); if ((int)o["code"] != 0) { messShow.Show("发送失败," + o["message"].ToString(), 2000); } else { txt_Content.Text = ""; } //RaisePropertChanged("messages"); } catch (Exception ex) { messShow.Show("发送失败\r\n" + ex.Message, 2000); //throw; } }
private async void AttenBiliQuan() { wc = new WebClientClass(); string url_post = string.Format("http://www.im9.com/api/join.community.do?access_key={0}&actionKey=appkey&appkey={1}&build=418000&community_id={2}&mobi_app=android&platform=android&ts={3}", ApiHelper.access_key, ApiHelper._appKey_Android, 1, ApiHelper.GetTimeSpen); url_post += "&sign=" + ApiHelper.GetSign_Android(url_post); string result = await wc.PostResults(new Uri(url_post), string.Empty, "http://www.im9.com", "www.im9.com"); }
/// <summary> /// 刷新 /// </summary> /// <param name="access_key">access token</param> /// <param name="refresh_token">access token</param> /// <returns></returns> public async Task <ReturnModel> RefreshToken(string access_key, string refresh_token) { try { var url = "https://passport.bilibili.com/api/oauth2/refreshToken"; var data = $"access_token={access_key}&refresh_token={refresh_token}&appkey={ApiHelper.AndroidKey.Appkey}&ts={ApiHelper.GetTimeSpan}"; data += "&sign=" + ApiHelper.GetSign(data); var content = await WebClientClass.PostResults(new Uri(url), data); var obj = JObject.Parse(content); if (obj["code"].ToInt32() == 0) { var m = JsonConvert.DeserializeObject <Token_info>(obj["data"].ToString()); SettingHelper.Set_Access_key(m.access_token); SettingHelper.Set_Refresh_Token(m.refresh_token); SettingHelper.Set_LoginExpires(DateTime.Now.AddSeconds(m.expires_in)); SettingHelper.Set_UserID(m.mid); List <string> sso = new List <string>() { "https://passport.bilibili.com/api/v2/sso", "https://passport.biligame.com/api/v2/sso", "https://passport.im9.com/api/v2/sso" }; //foreach (var item in sso) //{ //} await SSO(m.access_token); MessageCenter.SendLogined(); return(new ReturnModel() { success = true, message = "刷新成功" }); } else { return(new ReturnModel() { success = false, message = "刷新Token失败,请重新登录" }); } } catch (Exception) { return(new ReturnModel() { success = false, message = "刷新Token失败,请重新登录" }); } }
private async void btn_Select_Click(object sender, RoutedEventArgs e) { try { pr_Load.Visibility = Visibility.Visible; Uri uri = new Uri("ms-appx:///Assets/avatar/ic_avatar" + new Random().Next(1, 12) + ".jpg"); FileOpenPicker openPicker = new FileOpenPicker(); openPicker.CommitButtonText = "选中此文件"; openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".gif"); openPicker.FileTypeFilter.Add(".png"); // 弹出文件选择窗口 StorageFile file = await openPicker.PickSingleFileAsync(); // 用户在“文件选择窗口”中完成操作后,会返回对应的 if (file == null) { messShow.Show("没有选择图片", 3000); return; } Stream stream = await file.OpenStreamForReadAsync(); string resutls = ""; // resutls = await WebClientClass.PostResults(new Uri(string.Format("https://account.bilibili.com/pendant/updateFace?type=jpg&size=s")), stream.AsInputStream(), "https://account.bilibili.com/site/updateface.html?type=face"); // resutls = await WebClientClass.PostResults(new Uri(string.Format("https://account.bilibili.com/pendant/updateFace?type=jpg&size=m")), stream.AsInputStream(), "https://account.bilibili.com/site/updateface.html?type=face"); resutls = await WebClientClass.PostResults(new Uri(string.Format("https://account.bilibili.com/pendant/updateFace?type=jpg&size=l")), stream.AsInputStream(), "https://account.bilibili.com/site/updateface.html?type=face"); JObject obj = JObject.Parse(resutls); if (obj["state"].ToString() == "OK") { MessageCenter.SendLogined(); messShow.Show("头像更换成功", 3000); } else { messShow.Show("头像更换失败", 3000); } } catch (Exception ex) { messShow.Show("头像更换失败\r\n" + ex.Message, 3000); } finally { pr_Load.Visibility = Visibility.Collapsed; GetProfile(); } }
private async void PostLocalHistory() { try { string url = string.Format("http://api.bilibili.com/x/history/add?_device=wp&_ulv=10000&access_key={0}&appkey={1}&build=5250000&platform=android", ApiHelper.access_key, ApiHelper._appKey); url += "&sign=" + ApiHelper.GetSign(url); string result = await WebClientClass.PostResults(new Uri(url), "aid=" + playNow.Aid); } catch (Exception) { } }
private async void Video_ListView_Favbox_ItemClick(object sender, ItemClickEventArgs e) { if (ApiHelper.IsLogin()) { try { //((FavboxModel)e.ClickedItem).fid Uri ReUri = new Uri("http://api.bilibili.com/x/v2/fav/video/add"); string content = string.Format( "access_key={0}&aid={2}&appkey={1}&build=520001&fid={3}&mobi_app=android&platform=android&re_src=90&ts={4}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, _aid, ((FavboxModel)e.ClickedItem).fid, ApiHelper.GetTimeSpan_2 ); content += "&sign=" + ApiHelper.GetSign(content); string result = await WebClientClass.PostResults(ReUri, content ); JObject json = JObject.Parse(result); if ((int)json["code"] == 0) { Utils.ShowMessageToast("收藏成功!", 2000); GetFavBox(); } else { if ((int)json["code"] == 11007) { Utils.ShowMessageToast("视频已经收藏!", 2000); //MessageDialog md = new MessageDialog("视频已经收藏!"); //await md.ShowAsync(); } else { Utils.ShowMessageToast("收藏失败!\r\n" + result, 2000); } } } catch (Exception ex) { Utils.ShowMessageToast("收藏失败!" + ex.Message, 2000); } } else { Utils.ShowMessageToast("请先登录!", 2000); } }
public async void SendDanmu2() { if (auto_text.Text.Length == 0) { AddComment("弹幕内容不能为空!", true); return; } if (auto_text.Text.Length > 20) { AddComment("必需少于20字!", true); return; } try { auto_text.IsEnabled = false; WebClientClass wc = new WebClientClass(); DateTime timeStamp = new DateTime(1970, 1, 1); //得到1970年的时间戳 long time = (DateTime.UtcNow.Ticks - timeStamp.Ticks) / 10000000; string sendText = string.Format("color=16777215&fontsize=25&mode=1&msg={0}&rnd={1}&roomid={2}", auto_text.Text, time, rommID); string result = await wc.PostResults(new Uri("http://live.bilibili.com/msg/send"), sendText); JObject jb = JObject.Parse(result); if ((int)jb["code"] == 0) { AddComment("我:" + auto_text.Text, true); if (LoadDanmu) { danmu.AddGunDanmu(new Controls.MyDanmaku.DanMuModel() { DanText = auto_text.Text, DanSize = "25", _DanColor = "16777215" }, true); } auto_text.Text = string.Empty; } else { AddComment("弹幕发送失败", true); } } catch (Exception) { AddComment("弹幕发送出现错误", true); } finally { auto_text.IsEnabled = true; } }
private async void btn_ClearHistory_Click(object sender, RoutedEventArgs e) { //http://api.bilibili.com/x/v2/history/clear?_device=android&_hwid=bd2e7034b953cffe&_ulv=10000&access_key=1a8cd71c9830c73819989dade872ff55&appkey=1d8b6e7d45233436&build=421000&mobi_app=android&platform=android&sign=69e2689cd0b82f9b67aef4624360ae1b try { wc = new WebClientClass(); string url = string.Format("http://api.bilibili.com/x/v2/history/clear?_device=android&access_key={0}&appkey={1}&build=421000&mobi_app=android&platform=android", ApiHelper.access_key, ApiHelper._appKey_Android); url += "&sign=" + ApiHelper.GetSign_Android(url); string results = await wc.PostResults(new Uri(url), ""); User_ListView_History.Items.Clear(); pageNum_His = 1; } catch (Exception) { } }
/// <summary> /// 添加稍后再看 /// </summary> /// <param name="aid">AV号</param> /// <returns></returns> public async Task <ReturnModel> AddToView(string aid) { try { string url = "https://api.bilibili.com/x/v2/history/toview/add"; string par = string.Format("aid={3}&access_key={0}&appkey={1}&ts={2}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, ApiHelper.GetTimeSpan, aid); par += "&sign=" + ApiHelper.GetSign(par); var str = await WebClientClass.PostResults(new Uri(url), par); JObject obj = JObject.Parse(str); if (obj["code"].ToInt32() == 0) { return(new ReturnModel() { success = true, message = "" }); } else { return(new ReturnModel() { success = false, message = obj["message"].ToString() }); } } catch (Exception ex) { if (LogHelper.IsNetworkError(ex)) { return(new ReturnModel() { success = false, message = "无法连接服务器,请检查网络连接" }); } else { LogHelper.WriteLog(ex); return(new ReturnModel() { success = false, message = "发生未处理错误,已记录" }); } } }
private async void doLike(CommentModel data) { if (!ApiHelper.IsLogin() && !await Utils.ShowLoginDialog()) { Utils.ShowMessageToast("请登录后再执行操作"); return; } try { var action = 0; if (data.action == 0) { action = 1; } string url = "https://api.bilibili.com/x/v2/reply/action"; string content = string.Format("access_key={0}&appkey={1}&platform=android&type={2}&rpid={4}&oid={3}&action={5}&ts={6}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, _type, _loadCommentInfo.oid, data.rpid, action, ApiHelper.GetTimeSpan_2); content += "&sign=" + ApiHelper.GetSign(content); var re = await WebClientClass.PostResults(new Uri(url), content); JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { if (data.action == 0) { data.action = 1; data.like += 1; } else { data.action = 0; data.like -= 1; } } else { Utils.ShowMessageToast(obj["message"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("操作失败"); // throw; } }
private async void Video_ListView_Favbox_ItemClick(object sender, ItemClickEventArgs e) { if (ApiHelper.IsLogin()) { try { WebClientClass wc = new WebClientClass(); Uri ReUri = new Uri("http://api.bilibili.com/x/favourite/video/add"); string QuStr = "jsonp=jsonp&fid=" + ((FavboxModel)e.ClickedItem).fid + "&aid=" + _aid; string result = await WebClientClass.PostResults(ReUri, QuStr); JObject json = JObject.Parse(result); if ((int)json["code"] == 0) { messShow.Show("收藏成功!", 2000); GetFavBox(); } else { if ((int)json["code"] == 11007) { messShow.Show("视频已经收藏!", 2000); //MessageDialog md = new MessageDialog("视频已经收藏!"); //await md.ShowAsync(); } else { messShow.Show("收藏失败!\r\n" + result, 2000); } } } catch (Exception ex) { messShow.Show("收藏失败!" + ex.Message, 2000); } } else { messShow.Show("请先登录!", 2000); } }
private async void btn_CancelFollow_Click(object sender, RoutedEventArgs e) { if (ApiHelper.IsLogin()) { try { Uri ReUri = new Uri("http://api.bilibili.com/x/relation/modify"); string content = string.Format( "access_key={0}&act=2&appkey={1}&build=45000&fid={2}&mobi_app=android&platform=android&re_src=90&ts={3}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, Uid, ApiHelper.GetTimeSpan_2 ); content += "&sign=" + ApiHelper.GetSign(content); string result = await WebClientClass.PostResults(ReUri, content ); JObject json = JObject.Parse(result); if ((int)json["code"] == 0) { Utils.ShowMessageToast("已取消关注", 3000); btn_AddFollow.Visibility = Visibility.Visible; btn_CancelFollow.Visibility = Visibility.Collapsed; MessageCenter.SendLogined(); } else { Utils.ShowMessageToast("取消关注失败\r\n" + json["message"].ToString(), 3000); } } catch (Exception ex) { Utils.ShowMessageToast("关注时发生错误\r\n" + ex.Message, 3000); } } else { Utils.ShowMessageToast("请先登录", 3000); } }
private async void ReplyAt(CommentModel m) { if (!ApiHelper.IsLogin() && !await Utils.ShowLoginDialog()) { Utils.ShowMessageToast("登录后再来回复哦"); return; } if (m.replyText.Trim().Length == 0) { Utils.ShowMessageToast("不能发送空白信息"); return; } try { string url = "https://api.bilibili.com/x/v2/reply/add"; var txt = "回复 @" + m.member.uname + ":" + m.replyText; string content = string.Format("access_key={0}&appkey={1}&platform=android&type={2}&oid={3}&ts={4}&message={5}&root={6}&parent={7}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, _type, _loadCommentInfo.oid, ApiHelper.GetTimeSpan_2, Uri.EscapeDataString(txt), m.root, m.rpid); content += "&sign=" + ApiHelper.GetSign(content); var re = await WebClientClass.PostResults(new Uri(url), content); JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { Utils.ShowMessageToast("回复评论成功"); m.replyText = ""; m.showReplyBox = Visibility.Collapsed; RefreshComment(); } else { Utils.ShowMessageToast(obj["message"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("发送评论失败"); // throw; } }
private async void btn_Delete_Click(object sender, RoutedEventArgs e) { try { foreach (GetFavouriteBoxsVideoModel item in User_ListView_FavouriteVideo.SelectedItems) { string results = await WebClientClass.PostResults(new Uri("http://space.bilibili.com/ajax/fav/mdel"), string.Format("fid={0}&aids={1}", fid, item.aid)); JObject jo = JObject.Parse(results); if ((bool)jo["status"]) { User_ListView_FavouriteVideo.Items.Remove(item); } } } catch (Exception ex) { await new MessageDialog("删除失败\r\n" + ex.Message).ShowAsync(); } }
private async void ReportDM(string dmid) { try { string results = await WebClientClass.PostResults(new Uri("http://interface.bilibili.com/dmreport"), string.Format("reportToAdmin=0&reason=&dm_inid={0}&dmid={1}", playNow.Mid, dmid), "http://www.bilibili.com"); if (results == "0") { Utils.ShowMessageToast("举报成功", 3000); } else { Utils.ShowMessageToast("举报失败", 3000); } } catch (Exception) { Utils.ShowMessageToast("举报错误", 3000); } }
private async void btn_Random_Click(object sender, RoutedEventArgs e) { try { pr_Load.Visibility = Visibility.Visible; Uri uri = new Uri("ms-appx:///Assets/avatar/ic_avatar" + new Random().Next(1, 12) + ".jpg"); RandomAccessStreamReference streamRef = RandomAccessStreamReference.CreateFromUri(uri); Windows.Storage.Streams.Buffer buffer = null; using (IRandomAccessStreamWithContentType fileStream = await streamRef.OpenReadAsync()) { buffer = new Windows.Storage.Streams.Buffer((uint)fileStream.Size); await fileStream.ReadAsync(buffer, (uint)fileStream.Size, InputStreamOptions.None); } Stream stream = WindowsRuntimeBufferExtensions.AsStream(buffer); string resutls = ""; // resutls = await WebClientClass.PostResults(new Uri(string.Format("https://account.bilibili.com/pendant/updateFace?type=jpg&size=s")), stream.AsInputStream(), "https://account.bilibili.com/site/updateface.html?type=face"); // resutls = await WebClientClass.PostResults(new Uri(string.Format("https://account.bilibili.com/pendant/updateFace?type=jpg&size=m")), stream.AsInputStream(), "https://account.bilibili.com/site/updateface.html?type=face"); resutls = await WebClientClass.PostResults(new Uri(string.Format("https://account.bilibili.com/pendant/updateFace?type=jpg&size=l")), stream.AsInputStream(), "https://account.bilibili.com/site/updateface.html?type=face"); JObject obj = JObject.Parse(resutls); if (obj["state"].ToString() == "OK") { MessageCenter.SendLogined(); messShow.Show("头像更换成功", 3000); } else { messShow.Show("头像更换失败", 3000); } } catch (Exception ex) { messShow.Show("头像更换失败\r\n" + ex.Message, 3000); } finally { pr_Load.Visibility = Visibility.Collapsed; GetProfile(); } }
private async void btn_Send_Click(object sender, RoutedEventArgs e) { if (txt_Comment.Text.Trim().Length == 0) { Utils.ShowMessageToast("检查下你的输入哦..."); return; } try { var text = txt_Comment.Text; string url = "https://api.bilibili.com/x/v2/reply/add"; string content = string.Format("access_key={0}&appkey={1}&platform=android&type={2}&oid={3}&ts={4}&message={5}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, _type, _oid, ApiHelper.GetTimeSpan_2, Uri.EscapeDataString(text)); content += "&sign=" + ApiHelper.GetSign(content); var re = await WebClientClass.PostResults(new Uri(url), content); JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { Utils.ShowMessageToast("发送评论成功"); State = true; this.Hide(); } else { State = false; Utils.ShowMessageToast(obj["message"].ToString()); } } catch (Exception) { State = false; Utils.ShowMessageToast("发送评论失败"); // throw; } }
private async void AddInfo(int type, string data) { try { string results = await WebClientClass.PostResults(new Uri("http://api.bilibili.com/x/dm/filter/user/add"), string.Format("type={0}&filter={1}&jsonp=jsonp", type, Uri.EscapeDataString(data)), "http://www.bilibili.com"); JObject obj = JObject.Parse(results); if ((int)obj["code"] == 0) { Utils.ShowMessageToast("已添加", 3000); } else { Utils.ShowMessageToast(obj["message"].ToString(), 3000); } } catch (Exception) { Utils.ShowMessageToast("添加失败", 3000); } }
private async void PostHistory(string aid) { try { WebClientClass wc = new WebClientClass(); string url = string.Format("http://api.bilibili.com/x/history/add?_device=wp&_ulv=10000&access_key={0}&appkey={1}&build=411005&platform=android", ApiHelper.access_key, ApiHelper._appKey); url += "&sign=" + ApiHelper.GetSign(url); string result = await wc.PostResults(new Uri(url), "aid=" + aid); } catch (Exception) { } }
public async void TouBi(int num) { UserClass getLogin = new UserClass(); if (getLogin.IsLogin()) { try { WebClientClass wc = new WebClientClass(); Uri ReUri = new Uri("http://www.bilibili.com/plus/comment.php"); string QuStr = "aid=" + Aid + "&rating=100&player=1&multiply=" + num; string result = await wc.PostResults(ReUri, QuStr); if (result == "OK") { messShow.Show("投币成功!", 3000); } else { messShow.Show("投币失败!" + result, 3000); } } catch (Exception ex) { messShow.Show("投币时发生错误\r\n" + ex.Message, 3000); } } else { messShow.Show("请先登录!", 3000); } }