You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
1.4 KiB

  1. <?php
  2. //调用
  3. require_once '../Common/Config.php';
  4. require_once '../Common/Function.php';
  5. echo 1;
  6. /* $sql="INSERT INTO qrcode(media_id,url,createtime) values('".$media_id."','".$Rurl."','".date("Y-m-d H:i:s")."')";
  7. $pdo = new PDO("sqlsrv:Server=".HOST.";Database=".DB, USER, PASSWORD);//5.6版本pdo连接sqlsrv
  8. $result=$pdo->exec($sql);
  9. $id= $pdo->lastInsertId(); */
  10. $access_token=getAccesstoken();
  11. $getOpenidListUrl="https://api.weixin.qq.com/cgi-bin/user/get?access_token=".$access_token;
  12. $getOpenidList=http_request($getOpenidListUrl);
  13. echo $getOpenidList;
  14. print_r(json_decode($getOpenidList,true));exit;
  15. if ($getOpenidList){
  16. write_log($getOpenidList);
  17. $openidList_obj=json_decode($getOpenidList);
  18. $ticket=$openidList_obj->ticket;
  19. write_log("qrcode.php-- $ticketUrl url获取ticket:".$ticket);
  20. }
  21. $qrcodeUrl="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".urlencode($ticket);
  22. write_log("$qrcodeUrl".$qrcodeUrl);
  23. $imageInfo=downloadImageFromWeiXin($qrcodeUrl);
  24. $dir="./Images";
  25. if (!is_dir($dir)){
  26. mkdir($dir);
  27. }
  28. $filename=$dir."/qrcode"."-".$id."-".time().".jpg";
  29. $local_file=fopen($filename, 'w');
  30. if ($local_file !==false){
  31. if(fwrite($local_file, $imageInfo["body"]) !== false){
  32. fclose($local_file);
  33. /* $filePath=dirname($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'])."/".$filename;
  34. downfile($filePath); */
  35. }
  36. }
  37. header("Location: $qrcodeUrl");
  38. exit;