模拟触屏版QQ空间上传图片问题。
第一步:上传图片。
http://up.qzone.com/cgi-bin/upload/cgi_upload_pic_v2
参数:
picture:【图片的Base64编码】
base64:1
hd_height:480【图片高度】
hd_width:320【图片宽度】
hd_quality:96【图片质量,好像只有70&96 ,数字大是高质量】
output_type:json
preupload:1
charset:utf-8
output_charset:utf-8
logintype:sid
Exif_CameraMaker:【照片exif】
Exif_CameraModel:【照片exif】
Exif_Time:【照片exif】
uin:17xxxx19【QQ号】
sid:Axxxxxxxxxxxxxxcwn【SID】
头信息:
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.8
Connection:keep-alive
Content-Length:53497
Content-Type:application/x-www-form-urlencoded
Host:up.qzone.com
Origin:http://m.qzone.com
Referer:http://m.qzone.com/infocenter?g_f=2425
User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 6_0_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5
返回结果:
{ "filelen" : 20319, "filemd5" : "c8c4211055a01684b2a0bc112a674170b9c6bf323d129c4c923aa869d566e25c"}
图片Base64编码处理方法:
public static String GetImageStr(String imgFilePath) {//
byte[] data = null;
// 读取图片字节数组
try {
InputStream in = new FileInputStream(imgFilePath);
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
// 对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);// 返回Base64编码过的字节数组字符串
}
第二步:
http://up.qzone.com/cgi-bin/upload/cgi_upload_pic_v2
参数:
output_type=json
preupload=2
md5=c8c4211055a01684b2a0bc112a674170b9c6bf323d129c4c923aa869d566e25c【第一步返回结果里的filemd5】
filelen=20319【第一步返回结果里的filelen】
batchid=1425463906390000【new Date().getTime()+"000"】
currnum=0
uploadNum=1
uploadtime=1425463906【(new Date().getTime()+"").substring(0, 10)】
uploadtype=1
upload_hd=1
albumtype=7
big_style=1
op_src=15001
charset=utf-8
output_charset=utf-8
uin=1xxxx19【QQ号】
sid=AVxxxxxxxxxxxxxxcwn【SID】
logintype=sid
mobile_dc=actiontype%3D2%26subactiontype%3D1%26reserves%3D1%26page_type%3D2%26app_id%3D7003
albumid=V1XXX6【相册ID】
desc=测试测试【图片描述】
platformid=52
platformsubid=11
但是返回结果:
{ "picinfo" : { "error" : -400 } }
发现是图片Base64编码 处理部分出错。
不知道怎么做了。
处理图片Base64编码:
http://qzonestyle.gtimg.cn/qzone/phone/m/v4/widget/photopicker/file2/index.js
http://qzonestyle.gtimg.cn/qzone/phone/m/v4/widget/jpegEncode2.js
/*********************************2015-06-03更新****************************************/