飞哥,这个是你之前发的原帖。
http://www.sufeinet.com/thread-17938-1-1.html
这个工具我下载了,群发功能我已经实现啦。现在想实现图片发送功能,我在网页上抓包了。可是我本地构造了怎么都不对。。。
这个是我代码:
[C#] 纯文本查看 复制代码 FileInfo fileInfo = new FileInfo(filepath);
filesize = fileInfo.Length.ToString();
Cookie sid = BaseService.GetCookie("wxsid");
Cookie uin = BaseService.GetCookie("wxuin");
Cookie m_webwx_data_ticket = BaseService.GetCookie("webwx_data_ticket");
string m_xmldata = "{\"UploadType\":2,\"BaseRequest\":{\"Uin\":" + uin.Value + ",\"Sid\":\"" + sid.Value + "\",\"Skey\":\"" + LoginService.SKey + "\",\"DeviceID\":\"" + "e828039767636410" + "\"},\"ClientMediaId\":" + GetTimeStamps() + ",\"TotalLen\":" + filesize + ",\"StartPos\":0,\"DataLen\":" + filesize + ",\"MediaType\":4,\"FromUserName\":\"" + me.UserName + "\",\"ToUserName\":\"" + user.UserName + "\",\"FileMd5\":\"" + GetMD5HashFromFile(filepath) + "\"}";
string Content = "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"id\""
+ "\r\n" + "\r\n" + "WU_FILE_1"
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"name\""
+ "\r\n" + "\r\n" + filename
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"type\""
+ "\r\n" + "\r\n" + "image/png"
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"lastModifiedDate\""
+ "\r\n" + "\r\n" + "Wed Jul 13 2017 " + DateTime.Now.ToString("HH:mm:ss") + " GMT+0800"
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"size\""
+ "\r\n" + "\r\n" + filesize
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"mediatype\""
+ "\r\n" + "\r\n" + "pic"
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"uploadmediarequest\""
+ "\r\n" + "\r\n" + m_xmldata
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"webwx_data_ticket\""
+ "\r\n" + "\r\n" + m_webwx_data_ticket.Value
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"pass_ticket\""
+ "\r\n" + "\r\n" + HttpUtility.UrlDecode(LoginService.Pass_Ticket)
+ "\r\n" + "-----------------------------2055292472890"
+ "\r\n" + "Content-Disposition: form-data; name=\"filename\"; filename=\"" + filename + "\""
+ "\r\n" + "Content-Type:image/png\r\n\r\n";
File.WriteAllText(System.Environment.CurrentDirectory + "\\11.txt", Content, Encoding.GetEncoding("gb2312"));
string endstr = "-----------------------------2055292472890--\r\n\r\n";
byte[] picbuffer = System.Text.Encoding.UTF8.GetBytes(File.ReadAllText("f:\\1234.png", Encoding.UTF8));
byte[] contentbuffer = System.Text.Encoding.UTF8.GetBytes(Content);
byte[] buffer4 = System.Text.Encoding.UTF8.GetBytes(endstr);
byte[] endcode = ComposeArrays(ComposeArrays(contentbuffer, picbuffer), buffer4);
string sss = Encoding.UTF8.GetString(endcode);
File.WriteAllText(System.Environment.CurrentDirectory + "\\11.txt", sss, Encoding.GetEncoding("gb2312"));
byte[] bytes = BaseService.SendPostRequests("https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json", sss, picbuffer);
string send_result = Encoding.UTF8.GetString(bytes);
return send_result;
参数什么的我和抓包的都比对了。。没问题 但是就是不返回资源id
每次都是返回如下:
[C#] 纯文本查看 复制代码 "{\n\"BaseResponse\": {\n\"Ret\": 0,\n\"ErrMsg\": \"\"\n}\n,\n\"MediaId\": \"\",\n\"StartPos\": 6285,\n\"CDNThumbImgHeight\": 0,\n\"CDNThumbImgWidth\": 0\n}\n"
按理说 Ret = 0是成功了。但是MediaId 却是空。昨天研究了一天都没搞定。。。发上来让大家看看。
大牛们搞过的指点一下呀~感谢感谢~
|