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);
}
}
}