文档给的结果就是在 回调处,直接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();
$body = $response->getBody();
$bodyContents = $body->getContents();