首頁  >  文章  >  後端開發  >  微信二維碼生成

微信二維碼生成

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
上一篇:php替代語法下一篇:php替代語法