标签:
//加载 vendor目录的phpqrcode.类文件
$a = vendor("phpqrcode.qrlib");
// 创建目录
echo mkdir(__ROOT__.‘/Uploads/qrcodes‘);
//生成文件名
$filename = __ROOT__.‘/Uploads/qrcodes/qrcode-‘.md5(UID).‘.png‘;
$errorCorrectionLevel = ‘L‘;
$matrixPointSize = 4;
$url = ‘http://163.com‘;
\QRcode::png($url, $filename, $errorCorrectionLevel, $matrixPointSize,2);
echo ‘<img src="‘.$filename.‘">‘;
----------------------------------------
百度app
/*二维码 */
public function qrcode(){
$wx[‘share_url‘] = $url = ‘http://‘.$_SERVER[‘HTTP_HOST‘].__ROOT__.‘/?r_uid=‘.UID;
$wx[‘url‘] = ‘http://‘.$_SERVER[‘HTTP_HOST‘].__SELF__;
$ch = curl_init();
$url = ‘http://apis.baidu.com/3023/qr/qrcode?qr=‘.$wx[‘share_url‘];
$header = array(
‘apikey:e7acb07121f84142a79795a37f8333b9‘, // apikey
);
// // 添加apikey到header
curl_setopt($ch, CURLOPT_HTTPHEADER , $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 执行HTTP请求
curl_setopt($ch , CURLOPT_URL , $url);
$res = curl_exec($ch); //发送请求
$a = json_decode($res);
// var_dump($a);
echo ‘<img src="‘.$a->url.‘">‘;
// // var_dump(json_decode($res));
// }
标签:
原文地址:http://www.cnblogs.com/leijiangsheng/p/5523154.html