zoukankan      html  css  js  c++  java
  • PHP 携带参数的二维码

    //带二维码的海报
    public function shopqrcode() {
    header('content-type:text/html;charset=utf-8');
    //配置APPID、APPSECRET
    $id=$_GET['uid'];
    $APPID = C('WX_APPID');
    $APPSECRET =C('WX_SECRET');
    //获取access_token
    $access_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$APPID&secret=$APPSECRET";
    //缓存access_token
    session_start();
    $_SESSION['access_token'] = "";
    $_SESSION['expires_in'] = 0;
    $ACCESS_TOKEN = "";
    if(!isset($_SESSION['access_token']) || (isset($_SESSION['expires_in']) && time() > $_SESSION['expires_in'])){

    $json =$this->httpRequest($access_token);
    $json = json_decode($json,true);
    // var_dump($json);
    $_SESSION['access_token'] = $json['access_token'];
    $_SESSION['expires_in'] = time()+7200;
    $ACCESS_TOKEN = $json["access_token"];
    }else{

    $ACCESS_TOKEN = $_SESSION["access_token"];
    }

    $qcode = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$ACCESS_TOKEN;
    $data = array();
    $data['scene'] =$id;
    $data['page'] = 'pages/login/welcome';
    $data['width'] = "150";
    $param = json_encode($data);
    //POST参数
    $result = $this->httpRequest($qcode, $param,"POST");
    //生成二维码
    //$filename="/mnt/data/wwwroot/bzl/Qrcode/$id".".png"; //保存
    $filename="./Qrcode/$id".".png";
    $aa=file_put_contents($filename, $result);
    if($aa){
    $img="https://".$_SERVER[SERVER_NAME]."/Qrcode/$id".".png";//返回二维码

    return $img;
    }else{
    $img="";
    return $img;
    }
    }

  • 相关阅读:
    P3396 哈希冲突 TJ
    U135884 膜法问题 TJ
    U135075 简单数列 TJ
    U135649 皇室战争 TJ
    SF&SJJG-ST表
    牛客NOIP集训三S 牛半仙的妹子数 TJ
    UVA297 四分树 Quadtrees TJ
    UVA679 小球下落 Dropping Balls TJ
    [ACM] CF水题记
    Hoppz的收藏夹
  • 原文地址:https://www.cnblogs.com/xiaoqiangjun/p/12911162.html
Copyright © 2011-2022 走看看