/// <summary> /// Get the list of users this user is followed by. /// Required scope: relationships. /// </summary> /// <returns>JSON result string.</returns> public async Task <string> GetFollowedByAsync(long userId) { using (HttpClient httpClient = new HttpClient()) { var response = await httpClient.GetAsync(RelationshipEndpointUrlsFactory.CreateUserFollowsUrl(userId, this.accessToken)); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(responseContent); } else { throw new InstagramAPIException(responseContent); } } }
/// <summary> /// Modify the relationship between the current user and the target user. /// Required scope: relationships. /// </summary> /// <param name="relationshipAction">One of follow/unfollow/block/unblock/approve/deny.</param> public async Task <string> PostRelationshipActionAsync(long userId, RelationshipActions relationshipAction) { using (HttpClient httpClient = new HttpClient()) { var response = await httpClient.PostAsync(RelationshipEndpointUrlsFactory.CreatePOSTRelationshipActionUrl(userId, this.accessToken, relationshipAction), null); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(responseContent); } else { throw new InstagramAPIException(responseContent); } } }
/// <summary> /// Get the list of users this user follows. /// Required scope: relationships. /// </summary> /// <returns>JSON result string.</returns> public async Task <string> GetFollowsAsync(string accessToken) { using (HttpClient httpClient = new HttpClient()) { Uri uri = RelationshipEndpointUrlsFactory.CreateUserFollowsUrl(accessToken); if (this.EnforceSignedRequests) { uri = uri.AddParameter("sig", Utilities.GenerateSig(InstagramAPIEndpoints.UserFollowedByEndpoint, 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); } } }
/// <summary> /// Modify the relationship between the current user and the target user. /// Required scope: relationships. /// </summary> /// <param name="relationshipAction">One of follow/unfollow/block/unblock/approve/deny.</param> public async Task <string> PostRelationshipActionAsync(long userId, string accessToken, RelationshipActions relationshipAction) { using (HttpClient httpClient = new HttpClient()) { Uri uri = RelationshipEndpointUrlsFactory.CreatePOSTRelationshipActionUrl(userId, accessToken, relationshipAction); if (this.EnforceSignedRequests) { uri = uri.AddParameter("sig", Utilities.GenerateSig(string.Format(InstagramAPIEndpoints.RelationshipEndpoint, userId), this.ClientSecret, uri.Query)); } var response = await httpClient.PostAsync(uri, null); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(responseContent); } else { throw new InstagramAPIException(responseContent); } } }