httpclient 新浪微博 图片上传
本帖最后由 zhanglehua1985 于 2011-11-26 15:23:09 编辑
谁实现了httpclient 模拟的新浪微博 图片上传,能不能帮帮我啊,不是用新浪API:
String boundary="xaamkrpvrooupsnsqyswrfkrrqffetee";
MultipartEntity multiEntity = new MyMultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,boundary,Charset.forName("UTF-8"));
post.setHeader("User-Agent",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)");
post.setHeader("Referer", "http://js.t.sinajs.cn/t4/home/static/swf/img/SinaCollage.swf?version=1322135457");
post.setHeader("Host","picupload.service.weibo.com");
post.setHeader("x-flash-version","11,1,102,55");
post.setHeader("Content-Type", "application/x-www-form-urlencoded");
post.setHeader("Cookie", str);
FileBody binaryContent = new FileBody(new File("d:\\1.jpg"), "image/jpeg");
multiEntity.addPart("pic1", binaryContent);
post.setEntity(multiEntity);
response = client.execute(post);
HttpEntity entity = response.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(entity
.getContent(), "utf8"));
result = IOUtils.toString(br);
post.abort();
System.out.println(result);
发送到服务器的流
POST /interface/pic_upload.php?app=miniblog&marks=1&logo=1&nick=%40%E7%B2%89%E6%88%91%E5%95%8A&url=weibo.com/2367805863&markpos=1&s=xml&cb=http://weibo.com/upimgback.html&rq=http%3A%2F%2Fphoto.i.weibo.com%2Fpic%2Fadd.php%3Fapp%3D1 HTTP/1.1
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)
Referer: http://js.t.sinajs.cn/t4/home/static/swf/img/SinaCollage.swf?version=1322135457
Host: picupload.service.weibo.com
x-flash-version: 11,1,102,55
Content-Type: application/x-www-form-urlencoded
Cookie: ALC=bt%3D1322290351%26cv%3D2.0%26et%3D1322895151%26uid%3D2367805863%26vf%3D0%26es%3D7437cbf67775c722af6cfa4a9b2d27f0;ALF=1322895151;ALF=1322895151;LT=1322290351;NSC_wjq_xfjcp.dpn_ipnfqbhf=ffffffff094113b145525d5f4f58455e445a4a423660;NSC_wjq_xfjcp.dpn_ipnfqbhf=ffffffff094113a745525d5f4f58455e445a4a423660;SSOLoginState=1322290352;SUE=es%3D6c9fccf3bea3e1f3565ade9d6eb63754%26ev%3Dv1%26es2%3Dfc418f9ed04514b62dcf649191d87187%26rs0%3DVWKq0EoR28kKg2YQWNqwQknNpLQ3UIHX9TH8BCxsTgnmRpd0aRPv6Eyu88Q8J7RhTVF6PDOXZcxDlt9e%252BSQSaHl%252BZ7pe6mNzXP6hkMI4JHGNg99CiAoO9yvMU6gH4TWByrvSOfZSi7L%252F7k8BxsITL1X34Q8LKC14WdQk7w9YIJE%253D%26rv%3D0;SUP=cv%3D1%26bt%3D1322290351%26et%3D1322376751%26lt%3D1%26uid%3D2367805863%26user%3Dtaobao2100.%252A%252A%26ag%3D9%26name%3Dtaobao2100%2540sina.com%26nick%3Dtaobao2100%26sex%3D%26ps%3D0%26email%3Dtaobao2100%2540sina.com%26dob%3D%26ln%3Dtaobao2100%2540sina.com%26os%3D%26fmp%3D%26lcp%3D%26us%3D1%26vf%3D0;SUR=uid%3D2367805863%26user%3Dtaobao2100.%252A%252A%26nick%3Dtaobao2100%26email%3Dtaobao2100%2540sina.com%26dob%3D%26ag%3D9%26sex%3D%26ssl%3D0;SUS=SID-2367805863-1322290352-XD-8jogn-83e5e9f69a7b2297c7ec878ada7f91c4;tgc=TGT-MjM2NzgwNTg2Mw==-1322290351-xd-2CC0B306697E19D99CD84AC6452BCAA8;
Content-Length: 43211
Connection: Keep-Alive