zoukankan      html  css  js  c++  java
  • 调用微信模版消息

     调用背景: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需要根据实际情况灵活调整。

  • 相关阅读:
    Node.js/Python爬取网上漫画
    webpack2配置
    Node多进程相关
    文件上传更新服务相关
    自己的php函数库
    记录
    jquery 小知识点
    自己写算法---java的堆的非递归遍历
    转虚函数,写的相当好啊
    公钥私钥 ssl/tsl的概念
  • 原文地址:https://www.cnblogs.com/skye-blog/p/8705863.html
Copyright © 2011-2022 走看看