/// <summary> /// Remove a comment either on the authenticated user's media or authored by the authenticated user. /// Required scope: comments. /// </summary> public async Task <string> DeleteMediaCommentAsync(string mediaId, string commentId) { using (HttpClient httpClient = new HttpClient()) { var response = await httpClient.DeleteAsync(CommentEndpointsUrlsFactory.CreateDELETECommentUrl(mediaId, commentId, this.accessToken)); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(responseContent); } else { throw new InstagramAPIException(responseContent); } } }
/// <summary> /// Create a comment on a media. Please email apidevelopers[at]instagram.com for access. /// Required scope: comments. /// </summary> /// <param name="mediaId"></param> /// <param name="text">Text to post as a comment on the media as specified in media-id.</param> public async Task <string> PostMediaCommentAsync(string mediaId, string text) { using (HttpClient httpClient = new HttpClient()) { var content = BuildFormUrlEncodedContent(this.accessToken, text); var response = await httpClient.PostAsync(CommentEndpointsUrlsFactory.CreatePOSTCommentUrl(mediaId), content); string responseContent = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { return(responseContent); } else { throw new InstagramAPIException(responseContent); } } }
/// <summary> /// Get a list of recent comments on a media object. The public_content permission scope is required to get comments for a media that does not belong to the owner of the access_token. /// Required scope: comments. /// </summary> /// <param name="mediaId"></param> /// <param name="accessToken" type="string"> /// <para> /// A valid access token. /// </para> /// </param> /// <returns>JSON result string.</returns> public async Task <string> GetMediaCommentsAsync(string mediaId, string accessToken) { using (HttpClient httpClient = new HttpClient()) { Uri uri = CommentEndpointsUrlsFactory.CreateGETCommentsUrl(mediaId, accessToken); if (this.EnforceSignedRequests) { uri = uri.AddParameter("sig", Utilities.GenerateSig(string.Format(InstagramAPIEndpoints.CommentsEndpoint, mediaId), 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); } } }