/// <summary> /// Delete a media story (photo or video) /// </summary> /// <param name="mediaId">Story media id</param> /// <param name="sharingType">The type of the media</param> /// <returns>Return true if the story media is deleted</returns> public async Task <IResult <bool> > DeleteStoryAsync(string storyMediaId, InstaSharingType sharingType = InstaSharingType.Video) { UserAuthValidator.Validate(_userAuthValidate); try { var deleteMediaUri = UriCreator.GetDeleteStoryMediaUri(storyMediaId, sharingType); var data = new JObject { { "_uuid", _deviceInfo.DeviceGuid.ToString() }, { "_uid", _user.LoggedInUser.Pk }, { "_csrftoken", _user.CsrfToken }, { "media_id", storyMediaId } }; var request = HttpHelper.GetSignedRequest(HttpMethod.Post, deleteMediaUri, _deviceInfo, data); var response = await _httpRequestProcessor.SendAsync(request); var json = await response.Content.ReadAsStringAsync(); if (response.StatusCode != HttpStatusCode.OK) { return(Result.UnExpectedResponse <bool>(response, json)); } var deletedResponse = JsonConvert.DeserializeObject <DeleteResponse>(json); return(Result.Success(deletedResponse.IsDeleted)); } catch (Exception exception) { _logger?.LogException(exception); return(Result.Fail <bool>(exception)); } }
async Task ShareStory(InstaDirectInboxThread thread, InstaSharingType type) { try { if (thread.Title.Contains("FAKETHREAD")) { var userIds = new List <long>(); foreach (var user in thread.Users) { userIds.Add(user.Pk); } var shareStory = await Helper.InstaApi.StoryProcessor.ShareStoryAsync(ReelFeed.Id, StoryItem.Id, null, userIds.ToArray(), MessageText.Text, type); } else { var shareStory = await Helper.InstaApi.StoryProcessor.ShareStoryAsync(ReelFeed.Id, StoryItem.Id, new string[] { thread.ThreadId }, null, MessageText.Text, type); } } catch { } }
/// <summary> /// Share story to someone /// </summary> /// <param name="reelId">Reel id</param> /// <param name="storyMediaId">Story media id</param> /// <param name="threadId">Thread id</param> /// <param name="text">Text to send (optional</param> /// <param name="sharingType">Sharing type</param> public async Task <IResult <InstaSharing> > ShareStoryAsync(string reelId, string storyMediaId, string threadId, string text, InstaSharingType sharingType = InstaSharingType.Video) { UserAuthValidator.Validate(_userAuthValidate); try { var instaUri = UriCreator.GetStoryShareUri(sharingType.ToString().ToLower()); var data = new JObject { { "action", "send_item" }, { "thread_ids", $"[{threadId}]" }, { "unified_broadcast_format", "1" }, { "reel_id", reelId }, { "text", text ?? "" }, { "story_media_id", storyMediaId }, { "_csrftoken", _user.CsrfToken }, { "_uid", _user.LoggedInUser.Pk.ToString() }, { "_uuid", _deviceInfo.DeviceGuid.ToString() }, }; var request = HttpHelper.GetSignedRequest(HttpMethod.Post, instaUri, _deviceInfo, data); request.Headers.Add("Host", "i.instagram.com"); var response = await _httpRequestProcessor.SendAsync(request); var json = await response.Content.ReadAsStringAsync(); if (response.StatusCode != HttpStatusCode.OK) { return(Result.Fail("Status code: " + response.StatusCode, (InstaSharing)null)); } var obj = JsonConvert.DeserializeObject <InstaSharing>(json); return(Result.Success(obj)); } catch (Exception exception) { Debug.WriteLine(exception.Message); _logger?.LogException(exception); return(Result.Fail <InstaSharing>(exception)); } }