[Google QR Code] QueryString生成QR Code行動條碼

Google charts提供非常方便的API,

chs: QR code 圖片大小
cht: 圖片類型,google charts用這個參數產生各種圖片,這裡當然就填qr
chl: 要藏在QR code裡的文字,必須編成punycode(urlencode)。
choe: 編碼。請注意只支援iso-8859-1, sjis, utf8。詳見API說明網頁。
chld: 其他參數。M是錯誤修正層次,有L, M, Q, H等四級;後面的數字是QR code周圍白邊的寬度。

可以產生QR Code圖片。(API說明)

http://code.google.com/intl/en/apis/chart/infographics/docs/qr_codes.html

以下面URL為例,紅色部份為關鍵參數

https://chart.googleapis.com/chart?chs=120×120&cht=qr&chl=http://www.google.com.tw&choe=UTF-8&chld=M|2

範例圖片:

<img alt=”範例圖” src=”https://chart.googleapis.com/chart?chs=120×120&cht=qr&chl=http://www.google.com.tw&choe=UTF-8&chld=M|2″ />

 

範例圖

<?php
// Create some random text-encoded data for a QR code.
header('content-type: image/png');
$url = 'https://chart.googleapis.com/chart?chid=' . md5(uniqid(rand(), true));
$chd = 't:';
for ($i = 0; $i < 150; ++$i) {
$data = rand(0, 100000);
$chd .= $data . ',';
}
$chd = substr($chd, 0, -1);

// Add image type, image size, and data to params.
$qrcode = array(
'cht' => 'qr',
'chs' => '300x300',
'chl' => $chd);

// Send the request, and print out the returned bytes.
$context = stream_context_create(
array('http' => array(
'method' => 'POST',
'content' => http_build_query($qrcode))));
fpassthru(fopen($url, 'r', false, $context));
?>

转载请注明出处:https://www.onexin.net/google-qr-code-querystring-generate-qr-code-mobile-barcodes/

随机文章:

1、为什么您要开独立网上商店的呢?需要代建网店,商城,购物平台请看这里^^
https://www.onexin.net/why-do-you-want-to-open-an-independent-online-store-it-need-to-build-on-behalf-of-the-shop-mall-shopping-platform-see-here/

2、WorkerMan高性能的PHP Socket 服务器框架的特性
https://www.onexin.net/workerman-php-socket/

3、PHP 5.3 与 Zend编译
https://www.onexin.net/compile-php-5-3-with-zend/

4、测试 $_SERVER[“REQUEST_TIME”] 和 time() 记录时间的区别
https://www.onexin.net/server-request_time/

5、IIS 服务器用命令杀死进程PID
https://www.onexin.net/with-the-command-to-kill-the-process/

Leave a Reply