国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信公眾號 客服接口的開發實例詳解

2024-07-22 01:16:53
字體:
來源:轉載
供稿:網友

微信平臺更新之后,發現客服接口不錯。研究了下 和大家分享下。

按照官方文檔,是向客服接口發送規定的JSon 就可以了。

首先先封裝下 JSon 的類:

package com.lwz.wx.bean.kf;// 這個是最外層的 也可以說是基類吧、public class Basebean {private String touser;private String msgtype;public String getTouser() {return touser;}public void setTouser(String touser) {this.touser = touser;}public String getMsgtype() {return msgtype;}public void setMsgtype(String msgtype) {this.msgtype = msgtype;}  }
//這個類是繼承基類、package com.lwz.wx.bean.kf;public class BaseNews extends Basebean{  private Kfnews news;public Kfnews getNews() {return news;}public void setNews(Kfnews news) {this.news = news;}}//
package com.lwz.wx.bean.kf;import java.util.List;public class Kfnews {private List<articles> articles;public List<articles> getArticles() {return articles;}public void setArticles(List<articles> articles) {this.articles = articles;}}//
package com.lwz.wx.bean.kf;public class articles {private String title;  private String description;  private String url;  private String picurl;public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public String getUrl() {return url;}public void setUrl(String url) {this.url = url;}public String getPicurl() {return picurl;}public void setPicurl(String picurl) {this.picurl = picurl;}}

以上的結構就對應

接下來就是對JSON 的數據的創建了

package com.lwz.wx.main;import java.util.ArrayList;import java.util.List;import org.apache.log4j.Logger;import net.sf.json.JSONObject;import com.lwz.wx.bean.AccessToken;import com.lwz.wx.bean.Articles;import com.lwz.wx.bean.kf.BaseNews;import com.lwz.wx.bean.kf.BaseText;import com.lwz.wx.bean.kf.Basebean;import com.lwz.wx.bean.kf.Kfnews;import com.lwz.wx.bean.kf.articles;import com.lwz.wx.bean.kf.text;import com.lwz.wx.util.WeixinUtil;public class KfManager {private final static Logger log = Logger.getLogger(Basebean.class);   public static void Gotokf(String openid){     String appId =""; //填上自己的APPID 下同  需要認證過的哦String appSecret="";// 調用接口獲取access_tokenAccessToken at = WeixinUtil.getAccessToken(appId, appSecret);if (null != at) {// 調用接口發送消息int result = WeixinUtil.Runkf( getkfnews(openid), at.getToken()); // 這個方法會在下面 展示//int result = WeixinUtil.createMenu(getMenu(),"1832148947");// 判斷菜單創建結果if (0 == result)log.info("調用客服信息發送成功!");elselog.info("客服調用失敗,錯誤碼:" + result);}  }            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 河西区| 永州市| 恩平市| 刚察县| 林州市| 读书| 平和县| 从江县| 修水县| 精河县| 翁源县| 获嘉县| 赤城县| 西安市| 奉新县| 托里县| 友谊县| 南郑县| 吉林市| 即墨市| 文化| 淮滨县| 陇南市| 武川县| 辽阳县| 凌海市| 温宿县| 宁远县| 乐亭县| 九寨沟县| 汝阳县| 襄垣县| 子洲县| 密云县| 垦利县| 南通市| 黄浦区| 双鸭山市| 正定县| 梁平县| 繁昌县|