借助Google大神要產生QRcode簡直是彈指之間的事,只要透過google chart api,一行連結便能產生QRcode圖片。

範例效果:

使用方式

我們先來看看上面那個QRcode是怎麼生成的,全貌就只是這樣一條簡單的連結

http://chart.apis.google.com/chart?cht=qr&choe=UTF-8&chs=300x300&chl=https%3A%2F%2Fblog.aidec.tw

要在網頁輸出成圖片,我們只要將連結放入<img> 就可以了~

<img src="http://chart.apis.google.com/chart?cht=qr&choe=UTF-8&chs=300x300&chl=https%3A%2F%2Fblog.aidec.tw" />

參數說明

接著下來,我們來拆解這連結的參數各自代表的意義。

qrcode01.JPG

完成文檔

https://developers.google.com/chart/infographics/docs/qr_codes

補充說明

如果qrcode的資料是用php產生的,建議將資料使用urlencode,這樣可讓資料編碼化,避免連結格式錯誤。

<img src="http://chart.apis.google.com/chart?cht=qr&choe=UTF-8&chs=300x300&chl=<?php echo urlencode('https://blog.aidec.tw');?>" />


文章轉載或引用,請先告知並保留原文出處與連結!!(單純分享或非營利的只需保留原文出處,不用告知)

原文連結:
https://blog.aidec.tw/post/gen-qrcode-google-chart-api