<?php

namespace App\Http\Controllers\Wechat\Qrcode;

use App\Http\Requests;
use Illuminate\Http\Request;
use EasyWeChat\Foundation\Application;

class QrcodesController
{
    public function __construct($_param)
    {
    	$this->param = $_param;
		$this->app = $_param['app'];
    }

    public function create_qrcode($type='temporary',$sceneId)
    {
    	v('create_qrcode:'.$sceneId);
    	$expire_seconds = 30*24*3600;// 过期时间
    	if($type == 'temporary'){
    		$result = $this->app->qrcode->temporary($sceneId, $expire_seconds);
    	}else{
    		$result = $this->app->qrcode->forever($sceneId);
    	}
    	
		$ticket = $result->ticket;
		$expireSeconds = $result->expire_seconds; // 有效秒数
		$url = $this->app->qrcode->url($ticket);// 二维码地址
		v('sceneId:'.$sceneId.' url:'.$url);

		return $url;
    }
   
}
