微信二维码生成

WBOY
发布: 2016-07-30 13:29:52
原创
1609 人浏览过

生成二维码的函数

<code><span>public</span><span><span>function</span><span>actionGenerateQrcode</span><span>()</span>
{</span><span>//获取设备id</span><span>$data</span>[<span>'device_id'</span>] = <span>$this</span>->getQuery(<span>'deviceid'</span>);
    <span>// require_once ($lib_file);</span>
    Yii::import(<span>'application.modules.Libraries.*'</span>);
    <span>$lib_file</span> = <span>'qrcode/phpqrcode.php'</span>;
    <span>require_once</span> (<span>$lib_file</span>);
    <span>// 纠错级别:L、M、Q、H</span><span>$errorCorrectionLevel</span> = <span>'M'</span>;
    <span>// 点的大小:1到10,2.6(64*64)</span><span>$matrixPointSize</span> = <span>5</span>;
    <span>$device</span> = DeviceComponent::shake(<span>$this</span>->accesstoken)->listbydevice(<span>$data</span>);
    <span>$url</span> = <span>$this</span>->generatedeviceurl(<span>$device</span>[<span>'devices'</span>][<span>0</span>]);
    QRcode::png(<span>$url</span>, <span>false</span>, <span>$errorCorrectionLevel</span>, <span>$matrixPointSize</span>, <span>2</span>);
    <span>exit</span>;
}</code>
登录后复制

生成二维码所需链接

<code><span>public</span><span><span>function</span><span>generatedeviceurl</span><span>(<span>$data</span> = array<span>()</span>)</span>
{</span><span>$url</span> = <span>"https://zb.weixin.qq.com/nearby/device/v3/clipboard.xhtml?uuid="</span>.<span>$data</span>[<span>'uuid'</span>].<span>"&major="</span>.<span>$data</span>[<span>'major'</span>].<span>"&minor="</span>.<span>$data</span>[<span>'minor'</span>];
    <span>return</span><span>$url</span>;
}</code>
登录后复制

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了微信二维码生成,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板