產生二維碼的函數
<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教程有興趣的朋友有幫助。