首页  >  文章  >  后端开发  >  微信二维码生成

微信二维码生成

WBOY
WBOY原创
2016-07-30 13:29:521595浏览

生成二维码的函数

<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教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn