Open bamjohn2222 opened 4 years ago
(Please guys let me know if there's any problem with this) I made this by reading the project's code and finding out that the system gets the information from skip2 project and write it to terminal. So:
Add to import:
qrcode "github.com/skip2/go-qrcode"
Comment or delete from file:
go func() {
terminal := qrcodeTerminal.New()
terminal.Get(<-qr).Print()
}
Replace with this:
image := "qr.png"
qr := make(chan string)
go func() {
qrpng := <-qr
qrcode.WriteFile(qrpng, qrcode.Medium, 512, image)
}
This will write a file called qr.png in the same folder the app is running. To read it, what I do is keep listening for the file for some seconds to show it with an AJAX call.
The WriteFile function has some options, like raising the complexity of the qrcode and the image size. Read the code to see it, it's quite simple. I chose "Medium" and 512 according to my project. Sometimes the QR fails, the "Medium" option was safer after several tests in my project.
Thanks a lot fixed whatsapp qr detection for me.
@cleitonoliveira can you show example how to call the image with ajax sir ?
@rvp98 the app is a plain old jQuery and vanilla PHP, so I made a simple listener that tries to read the image for 10 seconds or just fails. The jQuery triggers the login (ajax) that generates the image, then triggers another call for a PHP file. The return is shown inside a DIV.
$count = 0;
while (!file_exists("qr.png")) {
if($count >= 10){
echo '<p>"Can't read the image."</p>';
}
sleep(1);
$count++;
}
$file = "path_to_file/qr.png";
$image = '<img src="'. $file.'" alt="QRcode">';
echo $image;
(Please guys let me know if there's any problem with this) I made this by reading the project's code and finding out that the system gets the information from skip2 project and write it to terminal. So:
Add to import:
qrcode "github.com/skip2/go-qrcode"
Comment or delete from file:
go func() { terminal := qrcodeTerminal.New() terminal.Get(<-qr).Print() }
Replace with this:
image := "qr.png" qr := make(chan string) go func() { qrpng := <-qr qrcode.WriteFile(qrpng, qrcode.Medium, 512, image) }
This will write a file called qr.png in the same folder the app is running. To read it, what I do is keep listening for the file for some seconds to show it with an AJAX call.
The WriteFile function has some options, like raising the complexity of the qrcode and the image size. Read the code to see it, it's quite simple. I chose "Medium" and 512 according to my project. Sometimes the QR fails, the "Medium" option was safer after several tests in my project.
how to display png in window form for scan
I am trying to move from terminal to web, and I need to convert it to qr code. But I dont know what kind of string is this ? and how do I convert it...Can anyone help?