我基本上正在嘗試使用Google的QR Code API從字節數組創建QR碼。我試着將'chl'變量(QR碼的數據)傳遞給Google的web後端一個字節數組,但它似乎從不喜歡它。我已經使用Google的PHP示例作爲我的代碼的基礎,但如果有人知道使用Google的API將字節數組簡單地轉換爲QR碼的替代方法,那麼這是唯一的目標。小文件到QR碼
<?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 = file($_FILES["file"]["tmp_name"]);
// Add image type, image size, and data to params.
$qrcode = array(
'cht' => 'qr',
'chs' => '300x300',
'choe' => 'ISO-8859-1',
'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));
?>
有PHP,處理上傳的文件並通過字節數組發送到谷歌的API。
請向我們展示您嘗試過的代碼。 – richsage
您可以嘗試將數據轉換爲十六進制。 – Blender
添加了一些PHP嘗試從上傳的文件發送字節數組。 – VashGH