为啥不给二维码服务器图片地址啊
//
function getToken(){
var loadurl=“https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=”+
getApp().data.appkey.appid+"&secret="+getApp().data.appkey.secret;
wx.request({ url: loadurl,method: ‘POST’,
header: {‘content-type’: ‘application/x-www-form-urlencoded’},
data: { }
,success: function (res) {
var access_token=res.data.access_token; console.log(access_token);
getCode(access_token);
}
});
}
function getCode(access_token){
var loadurl=“https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=”+access_token;
wx.request({ url: loadurl,method: ‘POST’,
//header: {‘content-type’: ‘application/x-www-form-urlencoded’},
data: {
“path”:“pag/index/index”,
“width”:200,
},success: function (res) {//图片 二进制流
pag.setData({img_code:res.data });
console.log(“图片”+res.data.length);
//for(var p in res.data){ console.log(p + " " + res.data[p]); }
}
});
}
为啥JAVA得不到图片流咯,在微信模拟器里面可以的
URL address=new URL(url);
HttpURLConnection uc=(HttpURLConnection)address.openConnection();
uc.setRequestProperty(“Connection”, “keep-alive”);
uc.setRequestProperty(“Accept”, “*/*”);
uc.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded; charset=UTF-8”);
uc.setRequestProperty(“Host”, “api.mch.weixin.qq.com”);
uc.setRequestProperty(“X-Requested-With”, “XMLHttpRequest”);
uc.setRequestProperty(“Cache-Control”, “max-age=0”);
uc.setRequestProperty(“User-Agent”, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
uc.setRequestMethod(“POST”);
uc.setDoOutput(true);
OutputStream os = uc.getOutputStream();
os.write(where.getBytes()); // &password=admin
os.close();
uc.connect();
InputStream inputStream=uc.getInputStream();
InputStreamReader inputStreamReader=new InputStreamReader(inputStream,“utf8”);
BufferedReader news=new BufferedReader(inputStreamReader);
String line=news.readLine();
while (line!=null) {
result+=line; line=news.readLine();
}
news.close();
inputStreamReader.close();
inputStream.close();