【问题标题】:Generate QRCode without Windows-1252在没有 Windows-1252 的情况下生成 QRCode
【发布时间】:2019-05-31 15:35:47
【问题描述】:

您好,我用来生成二维码BaconQrCode。我无法将二维码发送到Google Authenticator

要生成二维码,我使用:GoogleAuthenticator

BaconQrCode 生成带有字符的二维码,例如:

otpauth%3A%2F%2Ftotp%2FLaravel%3Fsecret%3D3DNLF33LLMG7SN2XXX%26issuer%3Dname.surname%2540mydomain.com

我在 Google Authenticator 中检查并使用此代码:

otpauth://totp/Laravel?secret=3DNLF33LLMG7SN2XXX&issuer=name.surname%40mydomain.com

【问题讨论】:

  • 我真的没有看到任何问题。请尝试解释您的预期结果是什么以及您的实际结果有什么问题。
  • @DTul 我需要没有Windows-1252 字符的genareta QRCode。我需要普通字符。

标签: qr-code google-authentication


【解决方案1】:

我换功能getQRCodeGoogleUrl:

public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = array())
{
    $level = !empty($params['level']) && array_search($params['level'], array('L', 'M', 'Q', 'H')) !== false ? $params['level'] : 'M';
    if ($title !== null) {
        $getTitle = $title;
    }
    $urlencoded = "otpauth://totp/$name?secret=$secret&issuer=$getTitle&ecc=$level";
    return $urlencoded;
}

而我使用BaconQrCodeGenerator

$google_qrCodeUrl = $this->getQRCodeGoogleUrl($title, $secret, $mail);
$qrcode = new BaconQrCodeGenerator;
$qrCodeUrl = $qrcode->size(250)->generate($google_qrCodeUrl);

现在可以正常工作了;)

【讨论】:

    猜你喜欢
    • 2011-02-13
    • 1970-01-01
    • 2011-12-10
    • 2012-02-26
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-03
    相关资源
    最近更新 更多