java 实现微信服务器下载图片到自己服务器 此功能的实现需要注意java 中io流的操作及网路开发, &nb
实现代码:
public class PicDownload { public static InputStream getInputStream(String accessToken, String mediaid) { InputStream is = null; String url = "https://cache.yisu.com/upload/infORMation/20200623/121/114033"); while ((len = inputStream.read(data)) != -1) { fileOutputStream.write(data, 0, len); } } catch (IOException e) { e.printStackTrace(); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } } public static void getPic(String accessToken, String mediaId) { String requestUrl = "Http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID"; requestUrl = requestUrl.replace("ACCESS_TOKEN", accessToken).replace( "MEDIA_ID", mediaId); JSONObject jsonObject = WeixinUtil.httpRequest(requestUrl, "GET", null); System.out.println(jsonObject); } public static void main(String[] args) throws Exception { String accessToken = ""; String mediaId = ""; String picName = ""; saveImageToDisk(accessToken, mediaId, picName,"f:/"); } }
--结束END--
本文标题: java 实现微信服务器下载图片到自己服务器
本文链接: https://lsjlt.com/news/226109.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0