public static async Task SendEditPostAsync(CancellationTokenSource cts, string title, string content, List <string> fileNameList, List <string> fileRemoveList, int postId, int threadId) { title = CommonService.MyHtmlEncodeForSend(title); content = CommonService.ReplaceFaceLabel(content); content = CommonService.MyHtmlEncodeForSend(content); var postData = new List <KeyValuePair <string, object> >(); postData.Add(new KeyValuePair <string, object>("formhash", AccountService.FormHash)); postData.Add(new KeyValuePair <string, object>("subject", title)); postData.Add(new KeyValuePair <string, object>("message", $"{content.Trim()}{MessageTail}")); postData.Add(new KeyValuePair <string, object>("wysiwyg", "1")); postData.Add(new KeyValuePair <string, object>("usesig", "1")); postData.Add(new KeyValuePair <string, object>("tid", threadId)); postData.Add(new KeyValuePair <string, object>("pid", postId)); postData.Add(new KeyValuePair <string, object>("iconid", "0")); // 添加附件 foreach (var fileId in fileNameList) { postData.Add(new KeyValuePair <string, object>(string.Format("attachnew[{0}][description]", fileId), string.Empty)); } // 删除附件 foreach (var fileId in fileRemoveList) { postData.Add(new KeyValuePair <string, object>("attachdel[]", fileId)); } string url = string.Format("http://www.hi-pda.com/forum/post.php?action=edit&extra=&editsubmit=yes&mod=", threadId); await _httpClient.PostAsync(url, postData, cts); }
public static async Task <bool> SendPostReplyAsync(CancellationTokenSource cts, string noticeauthor, string noticetrimstr, string noticeauthormsg, string content, List <string> fileNameList, int threadId) { content = CommonService.ReplaceFaceLabel(content); content = CommonService.MyHtmlEncodeForSend(content); var postData = new List <KeyValuePair <string, object> >(); postData.Add(new KeyValuePair <string, object>("formhash", AccountService.FormHash)); postData.Add(new KeyValuePair <string, object>("wysiwyg", "1")); postData.Add(new KeyValuePair <string, object>("usesig", "1")); postData.Add(new KeyValuePair <string, object>("noticeauthor", "0")); postData.Add(new KeyValuePair <string, object>("noticetrimstr", "0")); postData.Add(new KeyValuePair <string, object>("noticeauthormsg", "0")); postData.Add(new KeyValuePair <string, object>("subject", string.Empty)); postData.Add(new KeyValuePair <string, object>("message", $"{noticetrimstr}{content.Trim()}{MessageTail}")); // 图片信息 foreach (var fileName in fileNameList) { postData.Add(new KeyValuePair <string, object>(string.Format("attachnew[{0}][description]", fileName), string.Empty)); } string url = string.Format("http://www.hi-pda.com/forum/post.php?action=reply&tid={0}&replysubmit=yes&inajax=1", threadId); string resultContent = await _httpClient.PostAsync(url, postData, cts); return(resultContent.Contains("您的回复已经发布")); }
public static async Task <bool> SendNewThreadAsync(CancellationTokenSource cts, string title, string content, List <string> fileNameList, int forumId) { title = CommonService.MyHtmlEncodeForSend(title); content = CommonService.ReplaceFaceLabel(content); content = CommonService.MyHtmlEncodeForSend(content); var postData = new List <KeyValuePair <string, object> >(); postData.Add(new KeyValuePair <string, object>("formhash", AccountService.FormHash)); postData.Add(new KeyValuePair <string, object>("wysiwyg", "1")); postData.Add(new KeyValuePair <string, object>("usesig", "1")); postData.Add(new KeyValuePair <string, object>("iconid", "0")); postData.Add(new KeyValuePair <string, object>("subject", title)); postData.Add(new KeyValuePair <string, object>("message", $"{content.Trim()}{MessageTail}")); postData.Add(new KeyValuePair <string, object>("attention_add", "1")); // 图片信息 foreach (var fileName in fileNameList) { postData.Add(new KeyValuePair <string, object>(string.Format("attachnew[{0}][description]", fileName), string.Empty)); } string url = string.Format("http://www.hi-pda.com/forum/post.php?action=newthread&fid={0}&extra=&topicsubmit=yes", forumId); string resultContent = await _httpClient.PostAsync(url, postData, cts); return(!resultContent.Contains("对不起,您两次发表间隔少于")); }