Skip to content

MessageAPI

liyiorg edited this page Jan 9, 2015 · 3 revisions

高级群发 (两种方式)

分组群发
//access_token
String access_token = "";
// 获取分组ID
Group group = UserAPI.groupsGet(access_token);
String gid = group.getGroups().get(0).getId();
//文本群发
MassTextMessage textMessage = new MassTextMessage("分组群发文本消息");
//设置分组
textMessage.setFilter(new Filter(false,gid));
MessageAPI.messageMassSendall(access_token, textMessage);

//媒体类型
//先上传图片文件 获取media_id
String media_id = "";
MassImageMessage imageMessage = new MassImageMessage(media_id);
imageMessage.setFilter(new Filter(false,gid));
MessageAPI.messageMassSendall(access_token,imageMessage);
根据openId列表群发
//access_token
String access_token = "";

//根据openId 群发
//文本群发
MassTextMessage textMessage2 = new MassTextMessage("openId 列表群发文本消息");
textMessage2.setTouser(new HashSet<String>());
textMessage2.getTouser().add("openid_1");
textMessage2.getTouser().add("openid_2");
MessageAPI.messageMassSend(access_token,textMessage2);

群发media_id 来源方式

  • 图文消息 MessageAPI.mediaUploadnews
  • 视频 MessageAPI.mediaUploadvideo
  • 语音 MediaAPI.mediaUpload
  • 图片 MediaAPI.mediaUpload

API 列表

Clone this wiki locally