pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.08k stars 3.59k forks source link

Exporting qr to the web #2400

Closed ornsteindss closed 1 year ago

ornsteindss commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe.

Hello, is there any possible way to export QR in base64 image to other resource? So , for example the venom-bot library gives you the qr code in base64, and you can display it on client side somewhere, but here with client.on('qr'.... i'm receiving some string m that contains iside data-ref property in

tag on whatsapp page, but i don't think i can do something with it to display this qr in browser somewhere else.

For example this is what i'm receiving on qr event : 2@wq1v8z7buLZQlKol8OWvUQedvzfuRBvysXjyOr8nrpbsUMUgXgUIxxeCkSorQTcVlVu/ODHo3HvGnA==,3kOyh0clWuMOfOzTjOEoetlZ2KonJ4IGdwa+y8G3Pj4=,jXU27U6mqIQf2HY+EYBA7of6iUjb9gMRg/uWnLHIZWc=,fyF4eUbNT+OipHF+Asvmn8/kKdwGdcg5aIKvpSLg3RA=,1

Describe the solution you'd like.

Thanks for the answer

Describe an alternate solution.

No response

Additional context

No response

DarleiSidegum commented 1 year ago

Hi, You can use a library to convert the generated QR code string into an image for display.

realniceping commented 1 year ago

use qrcode-terminal - https://www.npmjs.com/package/qrcode-terminal, and sometimes stack overflow

const qrcode = require('qrcode-terminal'); const { Client, LocalAuth } = require('whatsapp-web.js'); const client = new Client({ authStrategy: new LocalAuth({ clientId : "arsen" }), puppeteer: { args: ['--no-sandbox'], } });

client.on('qr', (qr: any) => { // Generate and scan this code with your phone qrcode.generate(qr, {small: true}); console.log('QR RECEIVED', qr); });

ornsteindss commented 1 year ago

Hi, You can use a library to convert the generated QR code string into an image for display.

use qrcode-terminal - https://www.npmjs.com/package/qrcode-terminal, and sometimes stack overflow

const qrcode = require('qrcode-terminal'); const { Client, LocalAuth } = require('whatsapp-web.js'); const client = new Client({ authStrategy: new LocalAuth({ clientId : "arsen" }), puppeteer: { args: ['--no-sandbox'], } });

client.on('qr', (qr: any) => { // Generate and scan this code with your phone qrcode.generate(qr, {small: true}); console.log('QR RECEIVED', qr); });

Thanks for your replies.