Example #1
0
        /// <summary>
        /// Get information about a tag object.
        /// </summary>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetTagInfoAsync(string tagName)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(TagEndpointsUrlsFactory.CreateTagInfoUrl(tagName, this.accessToken));

                string responseContent = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
        /// <summary>
        /// Get information about a tag object.
        /// </summary>
        /// <param name="accessToken" type="string">
        ///     <para>
        ///         A valid access token.
        ///     </para>
        /// </param>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetTagInfoAsync(string tagName, string accessToken)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                Uri uri = TagEndpointsUrlsFactory.CreateTagInfoUrl(tagName, accessToken);
                if (this.EnforceSignedRequests)
                {
                    uri = uri.AddParameter("sig", Utilities.GenerateSig(string.Format(InstagramAPIEndpoints.TagInfoEndpoint, tagName), this.ClientSecret, uri.Query));
                }
                var response = await httpClient.GetAsync(uri);

                string responseContent = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }