NewsQrcodeController.class.php
796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* 新闻预览二维码
* User: wangjiayu
* Date: 2017-12-22
*/
namespace Frontend\Controller\Index;
use Com\QRcode;
class NewsQrcodeController extends AbstractController
{
// 免登录
protected $_require_login = false;
/**
* @author wangjiayu
* @desc 新闻预览二维码扫码跳转
* @param Int article_id 新闻ID
*/
public function Index()
{
$article_id = I('get.article_id', '', 'trim');
if (empty($article_id)) {
E('_ERR_ARTICLE_ID_IS_EMPTY');
}
$url = oaUrl('Frontend/Index/NewsScan/Index', ['article_id' => $article_id]);
$qrCode = QRcode::png($url, false, QR_ECLEVEL_L, 12, 1);
header('Content-Type: image/png');
imagepng($qrCode);
exit;
}
}