Commit 94b82dcc authored by shiyu's avatar shiyu

getMenu2

parent 3da03434
......@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
......@@ -246,22 +247,30 @@ public class OfficialAccountApi {
}
public Result getMenu() {
public Result getMenu() throws IOException {
String token = getAccessToken();
String url = "https://api.weixin.qq.com/cgi-bin/menu/get" + "?access_token=" + token;
String url = "https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info" + "?access_token=" + token;
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
okHttpUtil.get();
String responseStr = okHttpUtil.async();
logger.info("getMenu接口返回原文1 :{}", responseStr);
String url2 = "https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info" + "?access_token=" + token;
OkHttpUtil okHttpUtil2 = OkHttpUtil.builder().url(url2);
okHttpUtil2.get();
String responseStr2 = okHttpUtil2.async();
logger.info("getMenu接口返回原文2 :{}", responseStr2);
logger.info("getMenu接口返回原文 :{}", responseStr);
Map map = new HashMap<>();
map.put("responseStr", responseStr);
String deleteUrl = "https://api.weixin.qq.com/cgi-bin/menu/delete" + "?access_token=" + token;
okHttpUtil = OkHttpUtil.builder().url(deleteUrl);
okHttpUtil.get();
String responseStr2 = okHttpUtil.async();
logger.info("删除接口返回原文 :{}", responseStr2);
map.put("responseStr2", responseStr2);
String json = "{\"button\":[{\"type\":\"miniprogram\",\"name\":\"换藏\",\"url\":\"\",\"appid\":\"wx5b4409448bf2c72b\",\"pagepath\":\"pages/home/index\"}]}";
Map paramMap = JsonUtils.toMap(json);
String createUrl = "https://api.weixin.qq.com/cgi-bin/menu/create" + "?access_token=" + token;
okHttpUtil = OkHttpUtil.builder().url(createUrl);
okHttpUtil.post(true);
okHttpUtil.addParams(paramMap);
String responseStr3 = okHttpUtil.async();
logger.info("创建接口返回原文 :{}", responseStr3);
map.put("responseStr3", responseStr3);
return Result.success(map);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment