微信测试号开发的时候报了"errcode":48008,"errmsg":"no permission for this msgtype hint

DanielHinton 2018-07-21 08:14:23
微信测试号发送图文消息的时候居然出现没有权限,不知道问题在哪里。。。求大神帮忙

json里面的那个mpnews类
public class Media {
private String media_id = "";

public String getMedia_id() {
return media_id;
}

public void setMedia_id(String media_id) {
this.media_id = media_id;
}
}


最外层的那个json类,忽略硬编码和工具老旧的辣眼睛的编码风格
public class SendEssay {
private List<String> touser= new ArrayList<String>();

private Integer send_ignore_reprint = 0;
private String msgtype = "mpnews";
private Media mpnews= new Media();
public List<String> getTouser() {
return touser;
}
public void setTouser(List<String> touser) {

this.touser = touser;
}

public String getMsgtype() {
return msgtype;
}
public void setMsgtype(String msgtype) {
this.msgtype = msgtype;
}

public Media getMpnews(){
return mpnews;
}

public void setMpnews(Media mpnews){
this.mpnews = mpnews;
}
public SendEssay(){
touser.add("oofxQ1owInSPu3cLqY-BQheEjeCs");
touser.add("oofxQ1t6PuKW7VgbFkTh1DrWE6jM");
}

public void setSend_ignore_reprint(Integer send_ignore_reprint){
this.send_ignore_reprint = send_ignore_reprint;
}

public Integer getSend_ignore_reprint(){
return send_ignore_reprint;
}
}

发送请求的类
public class WeixinTest {
public static void main(String[] args) {
try {
//AccessToken token = WeixinUtil.getAccessToken();
//System.out.println("票据"+token.getToken());
//System.out.println("有效时间"+token.getExpiresIn());

//String path = "D:/imooc.jpg";
//String mediaId = WeixinUtil.upload(path, token.getToken(), "thumb");
//System.out.println(mediaId);
// String token = WeixinUtil.getAccessToken().getToken();
// String filePath = "D:"+File.separator+"apple.jpg";
// String result = WeixinUtil.upload(filePath,token,"image");
//String result = WeixinUtil.translateFull("");

Essay essay = new Essay();
essay.setTitle("hello world");
essay.setAuthor("hinton");
essay.setContent("<p><a href=\"http://mmbiz.qpic.cn/mmbiz_jpg/Hj0Y2ugkZbNFTyiaezESEmPA0Vp31qFfPqHA7ewyF3bpdz4VJMicfDJb8h1TnHtw5tVKvXGVexJjiaTkuW0a5vqLg/0?wx_fmt=jpeg\"hello world<p>");
essay.setDigest("hello world");
essay.setShow_cover_pic(1);
essay.setThumb_media_id("LiEtvUPnJLfUvew2GiGVxxdouS38U1xsqzuEgUgfldY");
essay.setContent_source_url("www.baidu.com");
List<Essay> essayList = new ArrayList<Essay>();
essayList.add(essay);
String essayJson =WeixinUtil.postEssay(essayList);
String token = WeixinUtil.getAccessToken().getToken();
String url = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token="+token;
JSONObject jObject =WeixinUtil.doPostStr(url,essayJson);


String url1 = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token="+token;

//System.out.println(WeixinUtil.doGetStr(url));
SendEssay sendEssay = new SendEssay();
Media medis = new Media();
medis.setMedia_id(jObject.getString("media_id"));
sendEssay.setMpnews(medis);
JSONObject obj = new JSONObject();
System.out.println(obj.fromObject(sendEssay).toString());
System.out.println(WeixinUtil.doPostStr(url1, obj.fromObject(sendEssay).toString()).toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
...全文
857 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
vip_daisy 2020-01-07
  • 打赏
  • 举报
回复
isyoungboy 2018-12-04
  • 打赏
  • 举报
回复
测试号不允许群发消息
内容概要:本文围绕“基于共享储能服务的智能楼宇双层优化配置”展开研究,提出了一种结合上层共享储能配置优化与下层楼宇内部能源调度优化的双层协同模型,通过Matlab代码实现,旨在提升智能楼宇在复杂能源环境下的运行效率与经济性。研究充分考虑光伏出力、负荷需求等不确定性因素,引入多维核密度估计、场景生成与削减等技术进行不确定性建模,并融合需求响应、微电网调度等先进理念,实现了对综合能源系统中储能资源的高效配置与动态调控,具有较强的理论深度与工程应用价值。; 适合人群:具备电力系统、可再生能源、优化算法或综合能源系统等相关背景,从事科研、工程应用或课题研究的研发人员、研究生及高年级本科生。; 使用场景及目标:①应用于智能楼宇、园区微电网、虚拟电厂等场景中的储能规划与运行优化;②支撑高水平学术论文(如EI/SCI)的复现、课题申、毕业设计及实际项目的双层优化建模与求解实践。; 阅读建议:建议结合提供的Matlab代码进行实操演练,重点理解双层优化架构的设计逻辑、求解策略(如Benders分解、主从博弈等)及不确定性处理方法,同时可参考文中关联技术(如场景生成、需求响应)拓展研究思路与应用场景。

51,408

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧