Exemplo n.º 1
0
        /// <summary>
        /// Get the most recent media published by a user. May return a mix of both image and video types.
        /// </summary>
        /// <param name="count">Count of media to return.</param>
        /// <param name="minId">Return media later than this min_id.</param>
        /// <param name="maxId">Return media earlier than this max_id.</param>
        /// <param name="minTimestamp">Return media after this UNIX timestamp.</param>
        /// <param name="maxTimestamp">Return media before this UNIX timestamp.</param>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetUserRecentMediaByAccessTokenAsync(long userId, int count = 0, string minId = null, string maxId = null, long minTimestamp = 0, long maxTimestamp = 0)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(UserEndpointUrlsFactory.CreateUserRecentMediaByAccessTokenUrl(userId, this.accessToken, count, minId, maxId, minTimestamp, maxTimestamp));

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

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// See the authenticated user's feed. May return a mix of both image and video types.
        /// </summary>
        /// <param name="count">Count of media to return.</param>
        /// <param name="minId">Return media later than this min_id.</param>
        /// <param name="maxId">Return media earlier than this max_id.</param>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetUserFeedAsync(int count = 0, string minId = null, string maxId = null)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(UserEndpointUrlsFactory.CreateUserFeedUrl(this.accessToken, count, minId, maxId));

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

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get basic information about a user.
        /// </summary>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetUserBasicInfoAsync(long userId)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(UserEndpointUrlsFactory.CreateUserBasicInfoUrl(userId, this.accessToken));

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

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Search for a user by name.
        /// </summary>
        /// <param name="q">A query string.</param>
        /// <param name="count">Number of users to return.</param>
        /// <returns>JSON result string.</returns>
        public async Task <string> SearchUsersAsync(string q, int count = 0)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(UserEndpointUrlsFactory.CreateSearchUsersUrl(this.accessToken, q, count));

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

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// See the authenticated user's feed. May return a mix of both image and video types.
        /// </summary>
        /// <param name="accessToken">A valid access token.</param>
        /// <param name="count">Count of media to return.</param>
        /// <param name="minId">Return media later than this min_id.</param>
        /// <param name="maxId">Return media earlier than this max_id.</param>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetSelfRecentMediaAsync(string accessToken, int count = 0, string minId = null, string maxId = null)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                Uri uri = UserEndpointUrlsFactory.CreateSelfRecentMediaUrl(accessToken, count, minId, maxId);
                if (this.EnforceSignedRequests)
                {
                    uri = uri.AddParameter("sig", Utilities.GenerateSig(InstagramAPIEndpoints.SelfRecentMediaEndpoint, 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);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get basic information about a user.
        /// </summary>
        /// <param name="accessToken">A valid access token.</param>
        /// <returns>JSON result string.</returns>
        public async Task <string> GetUserBasicInfoAsync(long userId, string accessToken)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                Uri uri = UserEndpointUrlsFactory.CreateUserBasicInfoUrl(userId, accessToken);
                if (this.EnforceSignedRequests)
                {
                    uri = uri.AddParameter("sig", Utilities.GenerateSig(string.Format(InstagramAPIEndpoints.UserBasicInfoEndpoint, userId), 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);
                }
            }
        }