private async void btn_Delete_Click(object sender, RoutedEventArgs e) { if (!ApiHelper.IsLogin()) { return; } try { string url = "https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/rm_rp_dyn?access_key={0}&appkey={1}&build=5250000&platform=android&ts={2}"; url = string.Format(url, ApiHelper.AccessKey, ApiHelper.AndroidKey.Appkey, ApiHelper.TimeStamp2); url += "&sign" + ApiHelper.GetSign(url); string content = "uid={0}&dynamic_id={1}"; content = string.Format(content, ApiHelper.GetUserId(), _data.desc.dynamic_id, ApiHelper.AccessKey, ApiHelper.AndroidKey.Appkey, ApiHelper.TimeStamp2); var re = await WebClientClass.PostResultsUtf8(new Uri(url), content); Newtonsoft.Json.Linq.JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { Utils.ShowMessageToast("已经删除"); this.Frame.GoBack(); } else { Utils.ShowMessageToast("操作失败" + obj["message"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("操作发生错误"); } }
private async void SendDynamic() { if (txt_Comment.Text.Trim().Length == 0) { Utils.ShowMessageToast("不能发送空白动态"); } var ctrl = "[]"; var at_uids = ""; atlist.Clear(); var txt = txt_Comment.Text; if (atDisplaylist.Count != 0) { foreach (var item in atDisplaylist) { if (txt.Contains(item.text)) { atlist.Add(new AtModel() { data = item.data.ToString(), length = item.length - 2, location = txt.IndexOf(item.text), type = 1 }); var d = item.text.Replace("[", "").Replace("]", ""); txt = txt.Replace(item.text, d); at_uids += item.data.ToString() + ","; } } ctrl = JsonConvert.SerializeObject(atlist); at_uids = at_uids.Remove(at_uids.Length - 1, 1); atDisplaylist.Clear(); } List <SendImagesModel> send_pics = new List <SendImagesModel>(); foreach (var item in imgs) { send_pics.Add(new SendImagesModel() { img_height = item.image_height, img_size = item.image_size, img_src = item.image_url, img_width = item.image_width }); } var imgStr = JsonConvert.SerializeObject(send_pics); string setting = "{\"copy_forbidden\":0}"; try { string url = string.Format("http://api.vc.bilibili.com/link_draw/v1/doc/create?access_key={0}&appkey={1}&build=5250000&platform=android&src=bilih5&ts={2}", ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, ApiHelper.GetTimeSpan_2); url += "&sign" + ApiHelper.GetSign(url); string content = "category=3&pictures={0}&description={1}&setting={2}&at_uids={3}&at_control={4}&jumpfrom=110"; content = string.Format(content, Uri.EscapeDataString(imgStr), Uri.EscapeDataString(txt), Uri.EscapeDataString(setting), at_uids, Uri.EscapeDataString(ctrl)); var re = await WebClientClass.PostResultsUtf8(new Uri(url), content); Newtonsoft.Json.Linq.JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { SendState = true; Utils.ShowMessageToast("发表动态成功"); this.Hide(); } else { SendState = false; Utils.ShowMessageToast("发表动态失败" + obj["message"].ToString()); } } catch (Exception) { SendState = false; Utils.ShowMessageToast("发表动态发生错误"); } }
private async void LoadRepost() { //_data try { _repostLoading = true; pr_Load.Visibility = Visibility.Visible; noRepost.Visibility = Visibility.Collapsed; btn_LoadMoreRepost.Visibility = Visibility.Collapsed; string offset = "0"; if (ls_repost.Items.Count != 0) { offset = ls_repost.Items.Count.ToString(); } string url = "https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/view_repost"; string content = string.Format("_device=android&access_key={0}&appkey={1}&build=5250000&dynamic_id={2}&mobi_app=android&offset={5}&platform=android&src=bilih5&ts={3}&uid={4}", ApiHelper.AccessKey, ApiHelper.AndroidKey.Appkey, _data.desc.dynamic_id, ApiHelper.TimeStamp2, ApiHelper.GetUserId(), offset); content += "&sign=" + ApiHelper.GetSign(content); var re = await WebClientClass.PostResultsUtf8(new Uri(url), content); JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { if (obj["data"]["comments"] == null) { if (ls_repost.Items.Count != 0) { Utils.ShowMessageToast("没有更多转发了"); } else { noRepost.Visibility = Visibility.Visible; } return; } ObservableCollection <RepostModel> ls = Newtonsoft.Json.JsonConvert.DeserializeObject <ObservableCollection <RepostModel> >(obj["data"]["comments"].ToString()); if (ls_repost.Items.Count == 0) { ls_repost.ItemsSource = ls; } else { ls.ToList().ForEach(x => (ls_repost.ItemsSource as ObservableCollection <RepostModel>).Add(x)); } btn_LoadMoreRepost.Visibility = Visibility.Visible; _data.desc.repost = obj["data"]["total_count"].ToInt32(); } else { Utils.ShowMessageToast(obj["message"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("无法读取转发信息"); } finally { pr_Load.Visibility = Visibility.Collapsed; pivot.SelectedIndex = 0; _repostLoading = false; } }
private async void SendRepost() { var ctrl = "[]"; var at_uids = ""; atlist.Clear(); var txt = txt_Comment.Text; if (atDisplaylist.Count != 0) { foreach (var item in atDisplaylist) { if (txt.Contains(item.text)) { atlist.Add(new AtModel() { data = item.data.ToString(), length = item.length - 2, location = txt.IndexOf(item.text), type = 1 }); var d = item.text.Replace("[", "").Replace("]", ""); txt = txt.Replace(item.text, d); at_uids += item.data.ToString() + ","; } } ctrl = JsonConvert.SerializeObject(atlist); at_uids = at_uids.Remove(at_uids.Length - 1, 1); atDisplaylist.Clear(); } if (txt == "") { txt = "转发动态"; } try { string url = "https://api.live.bilibili.com/dynamic_repost/v1/dynamic_repost/repost?access_key={0}&appkey={1}&build=5250000&platform=android&ts={2}"; url = string.Format(url, ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, ApiHelper.GetTimeSpan_2); url += "&sign" + ApiHelper.GetSign(url); string content = "uid={0}&dynamic_id={1}&content={2}&at_uids={3}&ctrl={4}"; content = string.Format(content, ApiHelper.GetUserId(), _dynamicCardsModel.desc.dynamic_id, Uri.EscapeDataString(txt), at_uids, Uri.EscapeDataString(ctrl)); var re = await WebClientClass.PostResultsUtf8(new Uri(url), content); Newtonsoft.Json.Linq.JObject obj = JObject.Parse(re); if (obj["code"].ToInt32() == 0) { _dynamicCardsModel.desc.repost += 1; Utils.ShowMessageToast("转发成功"); this.Hide(); } else { Utils.ShowMessageToast("转发失败" + obj["message"].ToString()); } } catch (Exception) { Utils.ShowMessageToast("转发发生错误"); } }