我通过文档知道了这个是用户取消订阅的缘故,那我在h5开发的过程中如何使用wx-open-subscribe来让用户进行订阅,我没有找到demo,字典那段给的代码没有看懂,有没有大神帮助解答一下
在开发订阅通知的时候遇到了问题,希望大神来帮助一下?这是我的源代码 // 推送订阅通知 function sendSubscribeMessage($openId, $templateId, $accessToken) { //$url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={$accessToken}"; $url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/bizsend?access_token={$accessToken}"; $data = [ 'touser' => $openId, 'template_id' => $templateId, 'page' => $queUrl, 'data' => [ 'number1' => [ 'value' => '活动1' ], 'date2' => [ 'value' => '2023-10-01' ], ] ]; $dataJson = json_encode($data); $options = [ 'http' => [ 'header' => "Content-type: application/json", 'method' => 'POST', 'content' => $dataJson ] ]; $context = stream_context_create($options); $response = file_get_contents($url, false, $context); return json_decode($response, true); } // 获取access_token(不是用户的,是公众号的) $publicAccessToken = $getToken['access_token']; // 发送订阅通知 $response = sendSubscribeMessage($openId, $templateId, $publicAccessToken); // 打印响应结果(实际应用中应做相应处理) echo '<pre>'; print_r($response); echo '</pre>'; 第一个问题: $url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={$accessToken}"; $url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/bizsend?access_token={$accessToken}"; 这两个请求方式有什么不同? 第二个问题: 我的输出结果是 Array ( [errcode] => 43101 [errmsg] => user refuse to accept the msg rid: 67403316-467731bb-0e997a4d )
2024-11-22