Commit 26f6a7db authored by shiyu's avatar shiyu

getMenu3

parent cf07edea
...@@ -8,6 +8,10 @@ import com.wwdz.ch.db.dao.distribution.ImageCatelogDao; ...@@ -8,6 +8,10 @@ import com.wwdz.ch.db.dao.distribution.ImageCatelogDao;
import com.wwdz.ch.db.domain.distribution.ImageCatelog; import com.wwdz.ch.db.domain.distribution.ImageCatelog;
import com.xxdxxs.utils.JsonUtils; import com.xxdxxs.utils.JsonUtils;
import com.xxdxxs.utils.StringUtils; import com.xxdxxs.utils.StringUtils;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -264,14 +268,35 @@ public class OfficialAccountApi { ...@@ -264,14 +268,35 @@ public class OfficialAccountApi {
logger.info("删除接口返回原文 :{}", responseStr2); logger.info("删除接口返回原文 :{}", responseStr2);
map.put("responseStr2", responseStr2); map.put("responseStr2", responseStr2);
String json = "{\"button\":[{\"type\":\"miniprogram\",\"name\":\"换藏\",\"url\":\"\",\"appid\":\"wx5b4409448bf2c72b\",\"pagepath\":\"pages/home/index\"}]}"; String json = "{\"button\":[{\"type\":\"miniprogram\",\"name\":\"换藏\",\"url\":\"\",\"appid\":\"wx5b4409448bf2c72b\",\"pagepath\":\"pages/home/index\"}]}";
Map paramMap = JsonUtils.toMap(json); /* Map paramMap = JsonUtils.toMap(json);
String createUrl = "https://api.weixin.qq.com/cgi-bin/menu/create" + "?access_token=" + token; String createUrl = "https://api.weixin.qq.com/cgi-bin/menu/create" + "?access_token=" + token;
okHttpUtil = OkHttpUtil.builder().url(createUrl); okHttpUtil = OkHttpUtil.builder().url(createUrl);
okHttpUtil.post(true); okHttpUtil.post(true);
okHttpUtil.addParams(paramMap); okHttpUtil.addParams(paramMap);
String responseStr3 = okHttpUtil.async(); String responseStr3 = okHttpUtil.async();
logger.info("创建接口返回原文 :{}", responseStr3); logger.info("创建接口返回原文 :{}", responseStr3);
map.put("responseStr3", responseStr3); map.put("responseStr3", responseStr3);*/
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = RequestBody.create(JSON, json);
Request request = new Request.Builder()
.url(deleteUrl)
.post(requestBody)
.build();
try {
okhttp3.Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
String responseBody = response.body().string();
logger.info("创建接口返回原文 :{}", responseBody);
map.put("responseStr3", responseBody);
} else {
System.out.println("Unexpected code " + response);
}
} catch (Exception e) {
e.printStackTrace();
}
return Result.success(map); return Result.success(map);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
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