예제 #1
0
        /// <summary>
        /// 投币
        /// </summary>
        /// <param name="num">数量</param>
        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);
            }
        }
 private async void PostHistory()
 {
     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)
     {
     }
 }
        private async void Video_ListView_Favbox_ItemClick(object sender, ItemClickEventArgs e)
        {
            UserClass getLogin = new UserClass();

            if (getLogin.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 wc.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);
            }
        }
예제 #4
0
        private async void createOrder()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                messShow.Show("开始创建订单", 2000);
                wc = new WebClientClass();
                string tokenString = await wc.GetResults(new Uri("http://bangumi.bilibili.com/web_api/get_token"));

                TokenModel tokenMess = JsonConvert.DeserializeObject <TokenModel>(tokenString);
                if (tokenMess.code == 0)
                {
                    TokenModel token   = JsonConvert.DeserializeObject <TokenModel>(tokenMess.result.ToString());
                    string     results = await wc.PostResults(new Uri("http://bangumi.bilibili.com/web_api/create_order"), string.Format("pay_method=0&aid={0}&token={1}", aid, token.token));

                    OrderModel orderMess = JsonConvert.DeserializeObject <OrderModel>(results);
                    if (orderMess.code == 0)
                    {
                        OrderModel orderModel = JsonConvert.DeserializeObject <OrderModel>(orderMess.result.ToString());
                        this.Frame.Navigate(typeof(WebViewPage), orderModel.cashier_url);
                    }
                    else
                    {
                        messShow.Show("订单创建失败," + orderMess.message, 3000);
                    }
                }
                else
                {
                    messShow.Show("读取Token失败," + tokenMess.message, 3000);
                }
            }
            catch (Exception)
            {
                messShow.Show("订单创建失败,请稍后重试", 3000);
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }