public async Task <string> CreatePreviewEditPost(ForumReplyEntity forumReplyEntity) { if (forumReplyEntity == null) { return(string.Empty); } var form = new MultipartFormDataContent { { new StringContent("updatepost"), "action" }, { new StringContent(forumReplyEntity.PostId.ToString()), "postid" }, { new StringContent(HtmlEncode(forumReplyEntity.Message)), "message" }, { new StringContent(forumReplyEntity.ParseUrl.ToString()), "parseurl" }, { new StringContent("2097152"), "MAX_FILE_SIZE" }, { new StringContent("Preview Post"), "preview" } }; HttpResponseMessage response = await _webManager.PostFormData(Constants.EDIT_POST, form); Stream stream = await response.Content.ReadAsStreamAsync(); using (var reader = new StreamReader(stream)) { string html = reader.ReadToEnd(); var doc = new HtmlDocument(); doc.LoadHtml(html); HtmlNode[] replyNodes = doc.DocumentNode.Descendants("div").ToArray(); HtmlNode previewNode = replyNodes.FirstOrDefault(node => node.GetAttributeValue("class", "").Equals("inner postbody")); return(previewNode == null ? string.Empty : FixPostHtml(previewNode.OuterHtml)); } }
public async Task <bool> CreateNewThread(NewThreadEntity newThreadEntity) { if (newThreadEntity == null) { return(false); } var form = new MultipartFormDataContent { { new StringContent("postthread"), "action" }, { new StringContent(newThreadEntity.Forum.ForumId.ToString(CultureInfo.InvariantCulture)), "forumid" }, { new StringContent(newThreadEntity.FormKey), "formkey" }, { new StringContent(newThreadEntity.FormCookie), "form_cookie" }, { new StringContent(newThreadEntity.PostIcon.Id.ToString(CultureInfo.InvariantCulture)), "iconid" }, { new StringContent(HtmlEncode(newThreadEntity.Subject)), "subject" }, { new StringContent(HtmlEncode(newThreadEntity.Content)), "message" }, { new StringContent(newThreadEntity.ParseUrl.ToString()), "parseurl" }, { new StringContent("Submit Reply"), "submit" } }; HttpResponseMessage response = await _webManager.PostFormData(Constants.NEW_THREAD_BASE, form); return(response.IsSuccessStatusCode); }
public async Task <bool> SendPrivateMessage(NewPrivateMessageEntity newPrivateMessageEntity) { if (newPrivateMessageEntity == null) { return(false); } var form = new MultipartFormDataContent { { new StringContent("dosend"), "action" }, { new StringContent(newPrivateMessageEntity.Receiver), "touser" }, { new StringContent(newPrivateMessageEntity.Icon.Id.ToString(CultureInfo.InvariantCulture)), "iconid" }, { new StringContent(HtmlEncode(newPrivateMessageEntity.Title)), "title" }, { new StringContent(HtmlEncode(newPrivateMessageEntity.Body)), "message" }, { new StringContent("yes"), "parseurl" }, { new StringContent("yes"), "parseurl" }, { new StringContent("Send Message"), "submit" } }; HttpResponseMessage response = await _webManager.PostFormData(Constants.NEW_PRIVATE_MESSAGE_BASE, form); return(response.IsSuccessStatusCode); }