• 调用微信模版消息


     调用背景:ThinkPHP3.1框架WeixinModel.class.php[微信模型]

    public function sendSomeFuncMsg($openid,$param,$keyword1){
       $temp_text=array(
          "touser"=>$openid,
          "template_id"=>"微信模版id",
          "url"=>"http://".$_SERVER['HTTP_HOST'].U("Controller/action",array('param'=>$param)),
          "data"=>array(
             "first"=>array(
                "value"=>"标题[自定义]",
                "color"=>"#173177"
             ),
             "keyword1"=>array(
                "value"=>$keyword1,
                "color"=>"#173177"
             ),          
             "remark"=>array(
                "value"=>"点击详情查看更多[自定义]",
                "color"=>"#173177"
             )
          )
       );
       $token=$this->getToken();
       $msg=urldecode(json_encode($temp_text));
       $result=$this->curl->post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$token,$msg);
       $result=json_decode($result,true);
    }

     Tip:

    url为模版消息点击后的跳转链接(用户点击,跳转前台某页面)。如果是后台(如审核操作)发送模版消息,U方法此时为后台链接,不可用。url需要根据实际情况灵活调整。

  • 相关阅读:
    火星A+B
    分西瓜(DFS)
    H.数7(模拟)
    镜像树(dfs)
    锐雯上单不给就送(矩阵快速幂)
    STL容器
    优先队列(和fence repair完全一样)
    x位全排列(next_permutation)
    fence repair(队列水过)
    线段相交
  • 原文地址:https://www.cnblogs.com/skye-blog/p/8705863.html
Copyright © 2020-2023  润新知