码迷,mamicode.com
首页 > 编程语言 > 详细

Java获取永久图文素材中的网页端Url

时间:2018-10-30 12:07:09      阅读:471      评论:0      收藏:0      [点我收藏+]

标签:https   photo   static   sub   appid   bin   result   素材   out   

package com.epalmpay.test;

import com.alibaba.fastjson.JSON;
import com.epalmpay.util.HttpClientUtil;
import com.epalmpay.util.wxPhotoUpload;
import com.riversoft.weixin.common.oauth2.AccessToken;
import net.sf.json.JSONObject;

import java.util.HashMap;
import java.util.Map;


public class Test01 {



public static void main(String[] args) throws Exception {

String appid = "xxxxx";
String secret = "xxxxx";
AccessToken token = wxPhotoUpload.getAccessToken(appid,secret);
String access_token = token.getAccessToken();
String webUrl = "https://api.weixin.qq.com/cgi-bin/material/get_material?access_token="+access_token;
Map map = new HashMap();
map.put("media_id", "NyLawrJYev9kPkz31vESbzwyCGk9Vq5-XgQCoa8aGiI");
String s = JSON.toJSONString(map);
String webMessageUrl= HttpClientUtil.post(webUrl,s);
JSONObject object = JSONObject.fromObject(webMessageUrl);
net.sf.json.JSONObject resultJSON = net.sf.json.JSONObject.fromObject(object);
String back = String.valueOf(resultJSON.get("news_item"));
back = back.substring(1, back.length() - 1);
net.sf.json.JSONObject resultJSON1 = net.sf.json.JSONObject.fromObject(back);
if (resultJSON1.get("url") != null) {
webMessageUrl = resultJSON1.getString("url");
System.out.println(webMessageUrl);
}
}
}

Java获取永久图文素材中的网页端Url

标签:https   photo   static   sub   appid   bin   result   素材   out   

原文地址:https://www.cnblogs.com/jabez1992/p/9875911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!