评论

关键字匹配,回复多条内容

关键字匹配,回复多条内容

文档给的结果就是在 回调处,直接echo 打印出来。但是需求是要用户发一次内容,公众号回复两次。

改造前
if($eventKey == "fangguanlian"){
    $img = "";
}elseif ($eventKey == "shouqiankefu"){
    $img = "";
}elseif ($eventKey == "shouhoukefu"){
    $img = "";
}

$response = "FromUserName . "]]>ToUserName . "]]>" . time() . "
                              
                              ";
echo $response;die;

改造后,再加个客服推送
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=".$token;
$response = (new Client([
    'verify' => false,
]))->request('POST', $url, [
    'json' => [
        'touser' => $openid,
        'msgtype' => 'image',
        'image' => [
            'media_id' => $v['custom']
        ]
    ]  ]);
$statusCode = $response->getStatusCode(); // 获取 HTTP 状态码
$body = $response->getBody(); // 获取响应体
$bodyContents = $body->getContents(); // 将响应体内容作为字符串获取

最后一次编辑于  07-24  
点赞 0
收藏
评论
登录 后发表内容