NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
* [sendCustomNotice() -](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#sendCustomNotice() -) * [说明](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#说明) * [参数](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#参数) * [文本消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#文本消息) * [图片消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#图片消息) * [语音消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#语音消息) * [视频消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#视频消息) * [音乐消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#音乐消息) * [图文消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#图文消息) * [卡券消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#卡券消息) * [小程序卡片消息](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#小程序卡片消息) * [返回值](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#返回值) * [error](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#error) * [success](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#success) * [示例](http://s.w7.cc/index.php?c=wiki&do=view&id=1&list=1015#示例) ### sendCustomNotice() - ### 说明 ~~~ sendCustomNotice($data) ~~~ 发送客服消息 ### 参数 * $data 要发送的数据请求包(结构如下) * touser 粉丝openid * msgtype * text 文本消息 * image 图片消息 * voice 语音消息 * video 视频消息 * music 音乐消息 * news 图文消息 * wxcard 卡劵消息 * miniprogrampage 小程序卡片消息 * 下面分类型说明发送内容具体参数 #### 文本消息 ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' 'msgtype': 'text', 'text': array( 'content': 'hello world' //文本消息内容 )) ~~~ #### 图片消息 ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' 'msgtype': 'image', 'image': array( 'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材ID )) ~~~ #### 语音消息 ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' 'msgtype': 'voice', 'voice': array( 'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材ID )) ~~~ #### 视频消息 ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' 'msgtype': 'video', 'video': array( 'title':'我的视频', 'description':'视频描述', 'media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //素材ID 'thumb_media_id':'oR5OU2VN0aCr9Kkg4lalkpzzdOc628ATnCmlfZdgJt4' //缩略图素材ID )) ~~~ #### 音乐消息 ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' 'msgtype': 'music', 'music': array( 'title':'我的音乐', //音乐消息的标题 'description':'音乐描述', //音乐消息的描述 'musicurl': 'http://we7.com/1.mp3', //音乐链接 'hqmusicurl':'http://we7.com/1.mp3', //高品质音乐链接,wifi环境优先使用该链接播放音乐 'thumb_media_id': 'oR5OU2VN0aCr9Kkg4lalkpzzdOc628ATnCmlfZdgJt4' //缩略图素材ID )) ~~~ #### 图文消息 发送图文消息(点击跳转到外链),图文消息条数限制在8条以内,注意,如果图文数超过8,则将返回错误: ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' 'msgtype': 'news', 'news': array( array( 'title':'Happy Day', 'description':'Is Really A Happy Day', 'url': 'http://we7.cc/', 'picurl':'http://we7.cc/1.jpg', ), array( 'title':'Happy Day', 'description':'Is Really A Happy Day', 'url': 'http://we7.cc/', 'picurl':'http://we7.cc/1.jpg', ) )) ~~~ 发送图文消息(点击跳转到图文消息页面),图文消息条数限制在8条以内,注意,如果图文数超过8,则将返回错误: ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4' 'msgtype': 'mpnews', 'mpnews': array( 'media_id':'oR5OU2VN0aCr9Kkg4lalki6pnvzxCGJEWX-x_8yU58Y', //图文消息素材ID )) ~~~ #### 卡券消息 ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4', 'msgtype': 'wxcard', 'wxcard': array( 'card_id': 'ah34j567d7kf8l4hje2ljle' //卡券ID )) ~~~ #### 小程序卡片消息 发送小程序卡片(要求小程序与公众号已关联): ~~~ array( 'touser': 'oPUOlw7yvucjUrZhzG6gd8VdILa4', 'msgtype': 'miniprogrampage', 'miniprogrampage': array( 'title': 'title', //小程序卡片的标题 'appid': 'appid', //小程序的appid,要求小程序的appid需要与公众号有关联关系 'pagepath': 'pages/index/index?foo=bar', //小程序的页面路径,跟app.json中一样 'thumb_media_id': 'oR5OU2VN0aCr9Kkg4lalkhvPRRd4AVl662uabDZrKBY' //小程序卡片图片的素材ID,小程序卡片图片建议大小为520*416 )) ~~~ ### 返回值 #### error 可用is\_error判断,详见《错误处理》 #### success 返回boolean值:true ### 示例 ~~~ $custom = array( 'msgtype' => 'text', 'text' => array('content' => urlencode('欢迎您再次订购!')), 'touser' => 'oPUOlw7yvucjUrZhzG6gd8VdILa4',);$account_api = WeAccount::create();$result = $account_api->sendCustomNotice($custom);print_r($result); ~~~