getQRUrl() 공개 메소드

获取二维码图片
public getQRUrl ( string $ticket ) : string
$ticket string 传入由getQRCode方法生成的ticket参数
리턴 string url 返回http地址
예제 #1
0
파일: index.php 프로젝트: blackzw/auth
     $ticket = $qrcode['ticket'];
     $sql = "insert into " . WEIXIN_TABLE . " (`Mac_ID`, `ticket`, `scene_id`,  `site`)\n                    values ('{$Mac_ID}', '{$ticket}', '{$scene_id}', '{$site}')";
 } else {
     $created_at = $result[0]['created_at'];
     $updated_at = $result[0]['updated_at'];
     $now = time();
     if ($now - strtotime($created_at) > $expire && $now - strtotime($updated_at) > $expire) {
         $qrcode = $weObj->getQRCode($result[0]['scene_id'], $type = 0, $expire);
         $ticket = $qrcode['ticket'];
         $updated_at = date("Y-m-d H:i:s");
         $sql = "update " . WEIXIN_TABLE . " set `ticket` = '{$ticket}', `updated_at` = '{$updated_at}' where `Mac_ID` = '{$Mac_ID}'";
     } else {
         $ticket = $result[0]['ticket'];
     }
 }
 $img = $weObj->getQRUrl($ticket);
 $mysql::query($sql);
 echo "<img src='{$img}'>";
 echo "<br>";
 echo "ps: expired after 30 min";
 echo "<br>";
 echo "<br>";
 echo "cellphone just followed the Wechat.......";
 ?>
 <img id="testImg" style="display:none">
 <script>
     var testImg = document.getElementById('testImg');
     testImg.src = 'http://www.ubnt.com.cn/static/images/promos-content-left.png?v=' + (+ new Date());
     var timer = setInterval(function(){
         testImg.src = 'http://www.ubnt.com.cn/static/images/promos-content-left.png?v=' + (+ new Date());
     }, 2000);
예제 #2
0
    echo json_encode($error1);
    exit;
}
if (isset($_GET['expire'])) {
    $expire = $_GET['expire'];
} else {
    $expire = 60;
}
$getStationUrl = $apiUrl . "/getStation.php?stationId=" . $stationId;
$getStation = json_decode(http_get($getStationUrl));
if ($getStation->status == 0) {
    $w = new Wechat($options);
    for ($i = 0; $i < 5; $i++) {
        $j = $i + 1;
        $ticket[$i] = $w->getQRCode($stationId, 0, $expire * $j);
        $qrcodeUrl[$i] = $w->getQRUrl($ticket[$i]['ticket']);
        $stationInfo[$i] = array('stationId' => $stationId, 'name' => $getStation->info->name, 'number' => $getStation->info->number, 'qrcodeUrl' => $qrcodeUrl[$i], 'expire_seconds' => $ticket[$i]['expire_seconds']);
    }
    $result = array('status' => 0, 'info' => $stationInfo);
    echo json_encode($result);
} else {
    echo json_encode($getStation);
    exit;
}
/**
 * GET 请求
 * @param string $url
 */
function http_get($url)
{
    $oCurl = curl_init();