【微信公共平台开发】二维码的获取

时间:2016-01-24 22:16:33   收藏:0   阅读:237
<?php
     $access_token="p3Tb67358J6l0zioGqNGnHSkbNES5ZDY88qZTZBaobJtN2udLrnrKnimzGpKvsC9ii0edJ6Yk2xnffkgbEVxWhzgREwvAmF0C7JFwNx9gYQNLUcAIAECL";
     //生成永久二维码
     $qrcode={"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 123}}};  
     $url="https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$access_token";
     $result=https_request($url,$qrcode);
     $jsoninfo=json_decode($result,true);
     $ticket=$jsoninfo[ticket];
     echo $ticket;
     
      function https_request($url,$data=null){
      $curl=curl_init();
      curl_setopt($curl, CURLOPT_URL, $url);
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
      curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
      if(!empty($data)){
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
      }
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      $output=curl_exec($curl);
      curl_close($curl);
      return $output;
     }

?>

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!