收藏
回答

php 调用微信公众号消息订阅功能接口报错,无法实现推广通知消息?

php 调用微信公众号消息订阅功能接口报错,无法实现推广通知消息?,返回结果 如下,要如何解决?是哪里错了?wx8ca0b9f968f63e8a

[{"errcode":40037,"errmsg":"invalid template_id rid: 672d2687-4d6ae76d-47b2cc1e"}]

调用代码如下

  //发送订阅消息
    function push_msg($access_token,$openid,$template_id,$content){

        $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;

        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
           "data" => array(
            "content" => array(
            "value" =>$content
        )
    )
);

        $data_json = json_encode($data);
//        Log::record('订阅参数信息',$data_json);

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'Content-Length: ' . strlen($data_json))
        );

        $response = curl_exec($ch);
        Log::record('订阅信息结果',$response);
        if (curl_errno($ch)) {
            echo 'Curl error: ' . curl_error($ch);
            Log::record('订阅信息结果','Curl error: ' . curl_error($ch));
        }

        curl_close($ch);

//        echo $response;
    }

最后一次编辑于  11-08
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容