Closed Link2Trials closed 3 years ago
Here's an running example you can use to start: https://phpsandbox.io/n/round-breeze-mzpk-pgrcn
Hi @antonioribeiro I am facing the exact same problem the qr image is not rendering at all. Can you please explain how to fix this?
Hi @antonioribeiro I am facing the exact same problem the qr image is not rendering at all. Can you please explain how to fix this?
Hey the solution was in this post
It had to do wit the setLocale function from php
i removed the setlocale and it worked
Actually;
$inlineUrl = $google2fa->getQRCodeInline( $companyName, $companyEmail, $secretKey );
Returns svg structure itself and not a url for <img src="{{ $inlineUrl }}" />
Which is causing the problem. Not sure how to fix this.
Actually;
$inlineUrl = $google2fa->getQRCodeInline( $companyName, $companyEmail, $secretKey );
Returns svg structure itself and not a url for
<img src="{{ $inlineUrl }}" />
Which is causing the problem. Not sure how to fix this.
$inlineUrl = $google2fa->getQRCodeInline( 'Name', $email, $secret );
this works when i remove the setLocale
Nevermind, I ended up rendering the svg structure as is.
Actually;
$inlineUrl = $google2fa->getQRCodeInline( $companyName, $companyEmail, $secretKey );
Returns svg structure itself and not a url for
<img src="{{ $inlineUrl }}" />
Which is causing the problem. Not sure how to fix this.
I encountered exactly the same issue @ahmed-raza (and can no longer view the example @antonioribeiro posted).
The fix was two-fold...
data:image/svg+xml;charset=utf-8,
).My final code looked like this and successfully rendered a QR Code in Chrome, Firefox and Edge...
<img src="data:image/svg+xml;charset=utf-8,{{ rawurlencode($inlineUrl) }}" alt="QR Code for Two-Factor Authentication" />
Actually;
$inlineUrl = $google2fa->getQRCodeInline( $companyName, $companyEmail, $secretKey );
Returns svg structure itself and not a url for<img src="{{ $inlineUrl }}" />
Which is causing the problem. Not sure how to fix this.I encountered exactly the same issue @ahmed-raza (and can no longer view the example @antonioribeiro posted).
The fix was two-fold...
- Utilise a Data URL by prefixing the data (in this case, the generated SVG structure) with a MIME type to indicate what type of data will follow (i.e.
data:image/svg+xml;charset=utf-8,
).- Percent-encode (URL-encode) the data using the PHP rawurlencode function.
My final code looked like this and successfully rendered a QR Code in Chrome, Firefox and Edge...
<img src="data:image/svg+xml;charset=utf-8,{{ rawurlencode($inlineUrl) }}" alt="QR Code for Two-Factor Authentication" />
The problem was similar. Fixed it on your advice. Thanks
i tried everything but on php 7.3.5 and 7.4.9 it doesent show the qrcode with this
$inlineUrl = $google2fa->getQRCodeInline( $companyName, $companyEmail, $secretKey );
<img src="<?php echo $inlineUrl;?>">