qr-code - Google Charts API(QR 码)返回 HTTP 错误 502
问题描述
您是否还有问题,您的二维码不再加载?这是因为 Google Charts 不再有效。谷歌在过去几天禁用了这项服务!因此,如果您正在苦苦挣扎,这就是原因:
https://groups.google.com/forum/#!topic/Google-chart-api/rZtHTyYgyXI
为此,您需要使用新的 Google 图表工具:
https://developers.google.com/chart/
我会弄清楚如何替换生成 QR 码的旧实现,并告诉你如何做到这一点。
解决方案
几个月前我遇到了这个问题,所以我只是做了我自己的二维码生成器,我使用 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');
这只是关于我解决这个问题的方式的一个想法。
推荐阅读
- c# - 使用 ActionResult 测试 web api 控制器
- asp.net - 复选框助手返回空值的问题 ASP.NET MVC
- python - heroku postgres 出错:未上传数据库
- c++ - 赋值运算符问题
- python - Python pandas过滤多列
- geoserver - WMS 级联 - otf 重投影
- mysql - 如何为触发器创建正确的语法?
- python - 在 Swift 和 Pythonkit 中使用 Python 模块
- google-apps-script - 当名称不存在时,GAS getSheetByName 退出进程
- sql-server - SQL Server 无法从特定服务器登录