Esempio n. 1
0
        /// <summary>
        /// Get the details of a pixiv illustration
        /// </summary>
        /// <param name="id">The id of the illustration</param>
        /// <returns>A PixivIllustration object that contains the illustration information</returns>
        public async Task <PixivIllustration> GetIllustrationDetail(string id, bool requireAuth = true)
        {
            Uri url = new Uri(baseUrl + "/v1/illust/detail");
            PixivRequestContent _query = new PixivRequestContent();

            _query.Add("illust_id", id);
            string resJson = await GetStringRequest(Method.GET, url, query : _query, requireAuth : requireAuth).ConfigureAwait(false);

            return(PixivIllustration.Parse(resJson, this, true));
        }
Esempio n. 2
0
        /// <summary>
        /// Get the detai of a pixiv user
        /// </summary>
        /// <param name="id">The user's id, if not specified it will return the detail of the current login user</param>
        /// <returns></returns>
        public async Task <PixivUserProfile> GetUserDetail(string id = null, bool requireAuth = true)
        {
            id = id ?? UserID;
            Uri url = new Uri(baseUrl + "/v1/user/detail");
            PixivRequestContent _query = new PixivRequestContent();

            _query.Add("user_id", id);
            _query.Add("filter", Filter);
            string resJson = await GetStringRequest(Method.GET, url, query : _query, requireAuth : requireAuth).ConfigureAwait(false);

            return(PixivUserProfile.Parse(resJson, this));
        }
Esempio n. 3
0
        internal async Task <string> GetStringRequest(RestSharp.Method method, Uri url,
                                                      PixivRequestHeader headers = null, PixivRequestContent query = null,
                                                      PixivRequestContent body   = null, bool requireAuth          = true)
        {
            headers = headers ?? new PixivRequestHeader();
            if (!(headers.ContainsKey("User-Agent") || headers.ContainsKey("user-agent")))
            {
                headers.Add("App-OS", "ios");
                headers.Add("App-OS-Version", "10.3.1");
                headers.Add("App-Version", "6.7.1");
                headers.Add("User-Agent", "PixivIOSApp/6.7.1 (iOS 10.3.1; iPhone8,1)");
            }

            if (requireAuth)
            {
                headers.Add("Authorization", $"Bearer {AccessToken}");
            }

            return(await base.GetStringRequest(method, url, headers, query, body).ConfigureAwait(false));
        }