上面是我调用获取二维码接口后返回的这串乱码,,,我查了下,,说这是图片的二进制流,,
那我应该怎么把它转换成图片呢???
朋友。这个问题很简单,如果是PHP的话,CURL请求时候,把他设置为文件流方式就行了。就是不存储为变量就oK了
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);//文件流方式输出
一楼的回答 太精辟了
$fpath = “./uploadd/11.jpg”; //图片的名称自己定
$file = fopen($fpath,“w”);//打开文件准备写入,$fpath为你在服务器上要保存的文件路径
fwrite($file,$tmpInfo);//写入文件,$jpg就是你获取的二维码图片流
fclose($file);//关闭
微信提供的http相关类,访问服务器都拿不到图片流
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost=HttpClientConnectionManager.getPostMethod(url);
HttpEntity entity= new StringEntity(json.toString(),“UTF-8”);
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
if (response != null) {
HttpEntity resEntity = response.getEntity();
System.out.println(EntityUtils.toString(resEntity, “UTF-8”));
}
{“errcode”:48001,“errmsg”:“api unauthorized hint: [gG5SwA0386vr67!]”}