|
- <?php
- //调用
- require_once '../Common/Config.php';
- require_once '../Common/Function.php';
- echo 1;
-
- /* $sql="INSERT INTO qrcode(media_id,url,createtime) values('".$media_id."','".$Rurl."','".date("Y-m-d H:i:s")."')";
- $pdo = new PDO("sqlsrv:Server=".HOST.";Database=".DB, USER, PASSWORD);//5.6版本pdo连接sqlsrv
- $result=$pdo->exec($sql);
- $id= $pdo->lastInsertId(); */
- $access_token=getAccesstoken();
-
- $getOpenidListUrl="https://api.weixin.qq.com/cgi-bin/user/get?access_token=".$access_token;
- $getOpenidList=http_request($getOpenidListUrl);
- echo $getOpenidList;
- print_r(json_decode($getOpenidList,true));exit;
- if ($getOpenidList){
- write_log($getOpenidList);
- $openidList_obj=json_decode($getOpenidList);
- $ticket=$openidList_obj->ticket;
- write_log("qrcode.php-- $ticketUrl url获取ticket:".$ticket);
- }
- $qrcodeUrl="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".urlencode($ticket);
- write_log("$qrcodeUrl".$qrcodeUrl);
- $imageInfo=downloadImageFromWeiXin($qrcodeUrl);
- $dir="./Images";
- if (!is_dir($dir)){
- mkdir($dir);
- }
- $filename=$dir."/qrcode"."-".$id."-".time().".jpg";
- $local_file=fopen($filename, 'w');
- if ($local_file !==false){
- if(fwrite($local_file, $imageInfo["body"]) !== false){
- fclose($local_file);
- /* $filePath=dirname($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'])."/".$filename;
- downfile($filePath); */
- }
- }
- header("Location: $qrcodeUrl");
- exit;
|