Пример #1
0
        public BiMessage MangaSign(string cookie)
        {
            BiMessage mangasing = new BiMessage();

            string          url = "https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn?platform=android";
            BiliApiResponse response;

            try
            {
                var result = _httphelper.ToPost(url, cookie, "");
                response = JsonConvert.DeserializeObject <BiliApiResponse>(result.Html);
            }
            catch (Exception)
            {
                //ignore
                //重复签到会报400异常,这里忽略掉
                mangasing.Code = 0;
                mangasing.Message.Add("今日已签到过,无法重复签到");
                return(mangasing);
            }

            if (response.Code == 0)
            {
                mangasing.Code = 1;
                mangasing.Message.Add("完成漫画签到");
                return(mangasing);
            }
            else
            {
                mangasing.Code = 0;
                mangasing.Message.Add("漫画签到异常");
                return(mangasing);
            }
        }
        /// <summary>
        /// 领取大会员每月赠送福利
        /// </summary>
        /// <param name="type">1.大会员B币券;2.大会员福利</param>
        private bool ReceiveVipPrivilege(int type, BiliCookie bilicookie, out string message)
        {
            string          csrf        = bilicookie.BiliJct;
            string          url         = string.Format("http://api.bilibili.com/x/vip/privilege/receive?type={0}&csrf={1}", type, csrf);
            var             response    = _httphelper.ToPost(url, bilicookie.CookieStr, "");
            BiliApiResponse apiResponse = JsonConvert.DeserializeObject <BiliApiResponse>(response.Html);
            var             name        = GetPrivilegeName(type);

            if (apiResponse.Code == 0)
            {
                _logger.LogDebug($"{name}成功");
                message = $"{name}成功";
                return(true);
            }
            else
            {
                _logger.LogError($"{name}失败,原因: {apiResponse.Message}");
                message = $"{name}失败,原因: {apiResponse.Message}";
                return(false);
            }
        }