Google 图表 API(二维码)returns HTTP 错误 502
Google Charts API (QR Code) returns HTTP error 502
您是否也遇到二维码无法加载的问题?这是因为 Google 图表不再处于活动状态。 Google 最近几天禁用了此服务!所以如果你正在挣扎,这就是原因:
https://groups.google.com/forum/#!topic/Google-chart-api/rZtHTyYgyXI
您需要为此使用新的 Google 图表工具:
https://developers.google.com/chart/
我会弄清楚如何替换生成二维码的旧实现,并让您知道如何执行此操作。
几个月前我遇到了这个问题,所以我自己做了一个二维码生成器,我用 Laravel 框架 (PHP) 来解决这个问题:
我第一次使用这个库:
simplesoftwareio/simple-qrcode
当然是PHP
像这样:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Str;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
class QrCodeController extends BaseController
{
/**
* @param $uuid
* @return mixed
*/
public function generate($parameter) {
$fileName = $parameter.'.png';
$file = storage_path()."/".$this->app_directory."/".$fileName;
QrCode::format('png')->size(1000)->generate($parameter, $file);
return Response::download($file, $fileName)->deleteFileAfterSend(true);
}
}
然后我只添加到路由文件:
Route::get('qr/{parameter}', 'QrCodeController@generate');
这只是我解决这个问题的想法。
如果你只是想像之前的 Google 一样使用 URL,我也找到了一个很好的解决方案:
问题是,新的 Google API 不再实施 QR 码 - 遗憾的是。
您是否也遇到二维码无法加载的问题?这是因为 Google 图表不再处于活动状态。 Google 最近几天禁用了此服务!所以如果你正在挣扎,这就是原因:
https://groups.google.com/forum/#!topic/Google-chart-api/rZtHTyYgyXI
您需要为此使用新的 Google 图表工具:
https://developers.google.com/chart/
我会弄清楚如何替换生成二维码的旧实现,并让您知道如何执行此操作。
几个月前我遇到了这个问题,所以我自己做了一个二维码生成器,我用 Laravel 框架 (PHP) 来解决这个问题:
我第一次使用这个库:
simplesoftwareio/simple-qrcode
当然是PHP
像这样:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Str;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
class QrCodeController extends BaseController
{
/**
* @param $uuid
* @return mixed
*/
public function generate($parameter) {
$fileName = $parameter.'.png';
$file = storage_path()."/".$this->app_directory."/".$fileName;
QrCode::format('png')->size(1000)->generate($parameter, $file);
return Response::download($file, $fileName)->deleteFileAfterSend(true);
}
}
然后我只添加到路由文件:
Route::get('qr/{parameter}', 'QrCodeController@generate');
这只是我解决这个问题的想法。
如果你只是想像之前的 Google 一样使用 URL,我也找到了一个很好的解决方案:
问题是,新的 Google API 不再实施 QR 码 - 遗憾的是。