微信公眾平臺 關注傳送客服圖文訊息 錯誤 errcode:40003及解決
阿新 • • 發佈:2018-11-19
使用微信公眾號傳送圖文訊息
http請求方式: POST
http請求url:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
所需json資料包:
{ "touser":"OPENID", "msgtype":"news", "news":{ "articles": [ { "title":"Happy Day", "description":"Is Really A Happy Day", "url":"URL", "picurl":"PIC_URL" } ] } }
遇到問題:
返回錯誤 invalid openID錯誤 errcode:40003,同樣的資料包在介面除錯工具裡可以傳送。
解決辦法:
picurl 在文件中的引數要求是
picurl 為必須引數並且圖片格式須按要求!
關注公眾號,傳送圖文訊息程式碼 java;
//關注公眾號 自動傳送 if (EventKey.equals("<![CDATA[subscribe]]>")) { String urlStr = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token="+ token; // 圖文回覆 String title = "感謝關注!";//標題 String Description = "高效安全,方便快捷。";//描述 String Url = "https://mp.weixin.qq.com/s?__biz=****==&mid=**********&idx=1&sn=*********";//點選圖文訊息跳轉連結 String PicUrl = "http://*********/img/1.jpg";//圖片地址 //拼接json包 String jsonstr = "{\"touser\":\"" + FromUserName + "\",\"msgtype\":\"news\",\"news\":{\"articles\":[{\"title\":\""+ title + "\",\"description\":\""+ Description + "\",\"url\":\""+ Url+ "\",\"picurl\":\""+ PicUrl+"\"}]}"; //傳送post請求 httpDownloader.uploadjson(urlStr, jsonstr); }