首页 新闻 会员 周边

php微信模板消息发送会执行一次,发送几十条消息

0
悬赏园豆:5 [已关闭问题] 关闭于 2017-02-11 09:54
<?php
function sendTemplateMsg(){ 
       $access_token = '我的access_token';
        $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$access_token;

        $array = array(
                'touser'=>'ovBdUwIs50k9o_ZMx8YFrKIfBCzY',
                'template_id'=>'supgjJ19TVDt4IqD3j19ftbnBhGwObegTIByo_hFgdQ',  //点击模板消息后的跳转链接
                'url'=>'http://www.sfkkkkkkkkk.com/',
                'data'=>array(
                    'name'=>array('value'=>'三只松鼠','color'=>'#173177'),
                    'money'=>array('value'=>338,'color'=>'#173177'),
                    'date'=>array('value'=>date("Y-m-d h:i:s"),'color'=>'#173177'),
                ),
            );
        //转换成json格式 
        $postJson = json_encode($array);

        //$res = $this->http_curl($url,'post','json',$postJson);
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$postJson);
        $res = curl_exec($ch);
        if(curl_errno($ch)){
            var_dump(curl_error($ch));
        }
        curl_close($ch);
        var_dump($res);

    }
    sendTemplateMsg();
?>

我在浏览器中访问这个页面时,可以成功的向我的微信号发送模板消息,access_token肯定没错

但是他会不停的发送消息,不知道为什么

< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册