🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 发送文本客服消息 > 代码示例 ~~~ $kf_data['touser'] = get_openid(); $kf_data['msgtype'] = 'text'; $kf_data['text']['content'] = '你好,欢迎使用豆信~'; sendCustomMessage($kf_data); ~~~ ## 发送图文客服消息 > 代码示例 ~~~ $articles[0] = array( 'title' => '单图文消息标题1', 'description' => '单图文消息描述1', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/bcPR8rBzAQhibbpsMEC1WOYIaD1l85XJRWCoricvUnfricBXO9eIuPEJgB2EsucewMYWjE3dLxohzINoxoaD6R6aA/0?wx_fmt=jpeg', 'url' => 'http://idouly.com/wenda/' ); $articles[1] = array( 'title' => '单图文消息标题2', 'description' => '单图文消息描述2', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/bcPR8rBzAQhibbpsMEC1WOYIaD1l85XJRWCoricvUnfricBXO9eIuPEJgB2EsucewMYWjE3dLxohzINoxoaD6R6aA/0?wx_fmt=jpeg', 'url' => 'http://idouly.com/wenda/' ); $articles[2] = array( 'title' => '单图文消息标题3', 'description' => '单图文消息描述3', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/bcPR8rBzAQhibbpsMEC1WOYIaD1l85XJRWCoricvUnfricBXO9eIuPEJgB2EsucewMYWjE3dLxohzINoxoaD6R6aA/0?wx_fmt=jpeg', 'url' => 'http://idouly.com/wenda/' ); $articles[3] = array( 'title' => '单图文消息标题4', 'description' => '单图文消息描述4', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/bcPR8rBzAQhibbpsMEC1WOYIaD1l85XJRWCoricvUnfricBXO9eIuPEJgB2EsucewMYWjE3dLxohzINoxoaD6R6aA/0?wx_fmt=jpeg', 'url' => 'http://idouly.com/wenda/' ); $kf_data['touser'] = get_openid(); $kf_data['msgtype'] = 'news'; $kf_data['news']['articles'] = $articles; sendCustomMessage($kf_data); ~~~ > 参数说明 @param $kf_data array 要发送的客服消息数组 > 补充说明 豆信封装了sendCustomMessage()来调用微信的多客服接口给用户主动发送消息,即此接口可以应用在任何插件的逻辑代码中,调用sendCustomMessage()接口可以在任何时刻主动给用户发送消息,但是要求发送对象必须与微信公众号在48小时内有互动,即用户在48小时内给微信公众号发过消息,否则调用sendCustomMessage()给用户主动发送消息无效。另外,此接口必须是认证的服务号才能使用。