【问题标题】:Google Charts API (QR Code) returns HTTP error 502Google Charts API(QR 码)返回 HTTP 错误 502
【发布时间】:2019-03-19 18:31:03
【问题描述】:

您是否也遇到无法加载二维码的问题?这是因为 Google Charts 不再有效。谷歌在过去几天禁用了这项服务!所以如果你在挣扎,这就是原因:

https://groups.google.com/forum/#!topic/Google-chart-api/rZtHTyYgyXI

您需要为此使用新的 Google 图表工具:

https://developers.google.com/chart/

我会弄清楚如何替换旧的生成 QR 码的实现,并告诉你如何做到这一点。

【问题讨论】:

    标签: qr-code


    【解决方案1】:

    几个月前我遇到了这个问题,所以我自己做了二维码生成器,我使用 Laravel Framework (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');
    

    这只是我解决这个问题的一个想法。

    【讨论】:

    • 感谢您分享您的方式!也是一个很好的独立解决方案。
    【解决方案2】:

    如果您以前只想使用类似 Google 的 URL,我也找到了一个很好的解决方案:

    http://goqr.me/api/

    问题是,新的 Google API 不再实现二维码 - 很遗憾。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      • 2014-12-12
      • 2018-11-25
      相关资源
      最近更新 更多