生成二维码的函数
public function actionGenerateQrcode()
{
//获取设备id
$data['device_id'] = $this->getQuery('deviceid');
// require_once ($lib_file);
Yii::import('application.modules.Libraries.*');
$lib_file = 'qrcode/phpqrcode.php';
require_once ($lib_file);
// 纠错级别:L、M、Q、H
$errorCorrectionLevel = 'M';
// 点的大小:1到10,2.6(64*64)
$matrixPointSize = 5;
$device = DeviceComponent::shake($this->accesstoken)->listbydevice($data);
$url = $this->generatedeviceurl($device['devices'][0]);
QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
exit;
}
生成二维码所需链接
public function generatedeviceurl($data = array())
{
$url = "https://zb.weixin.qq.com/nearby/device/v3/clipboard.xhtml?uuid=".$data['uuid']."&major=".$data['major']."&minor=".$data['minor'];
return $url;
}
时间: 2024-10-06 11:56:47