示例#1
0
        /// <summary>
        /// Get information about a location.
        /// </summary>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetLocationInfoAsync(long locationId)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(LocationEndpointsUrlsFactory.CreateLocationInfoUrl(locationId, this.accessToken));

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

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
        /// <summary>
        /// Get information about a location.
        /// </summary>
        /// <param name="accessToken" type="string">
        ///     <para>
        ///         A valid access token.
        ///     </para>
        /// </param>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetLocationInfoAsync(long locationId, string accessToken)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                Uri uri = LocationEndpointsUrlsFactory.CreateLocationInfoUrl(locationId, accessToken);
                if (this.EnforceSignedRequests)
                {
                    uri = uri.AddParameter("sig", Utilities.GenerateSig(string.Format(InstagramAPIEndpoints.LocationInfoEndpoint, locationId), 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);
                }
            }
        }