GithubHelp home page GithubHelp logo

Get QR Code on a page about sulla HOT 9 CLOSED

danielcardeenas avatar danielcardeenas commented on June 5, 2024
Get QR Code on a page

from sulla.

Comments (9)

smashah avatar smashah commented on June 5, 2024 3

Hi @yodaheis @CarlosEduR @NewZeek @Mrjavaci @MuallimCh

I've implemented this feature in v 1.2.3 of sulla-hotfix.

It uses the event emitter to grab the qr code when it's ready as base64.

You can see it here:
https://github.com/smashah/sulla#capturing-qr-code

Let me know if this works for you! Thanks

from sulla.

Mrjavaci avatar Mrjavaci commented on June 5, 2024 1

I am interested in this topic. I will return when I find a solution.

from sulla.

NewZeek avatar NewZeek commented on June 5, 2024 1

Hi, to send qrcode to frontend import fs to auth.js and save qrcode to html file.

const fs = require('fs');
//After case 2:
qrImage = _a.sent();
fs.writeFile('qrcode.html', '<html><body><img src="https://api.qrserver.com/v1/create-qr-code/?data=' + encodeURIComponent(qrImage) + '"></body></html>', (err) => {
  if (err) throw err;
  console.log('QrCode saved to file.');
});

Boa sorte.

from sulla.

MuallimCh avatar MuallimCh commented on June 5, 2024

Hello, Daniel! How are you?
I'm really grateful about the project you've done. I appreciate it.

I have a question: I got a freelancer job, and client would like to use this tool over browser, so I'd need to send QRCode to frontend.

Could you help me out on this issue?

in src/controllers/auth.ts
After const qrImage declaration, just create other const that coresponds to image itself, and show it to window.

Just my opinion.

from sulla.

CarlosEduR avatar CarlosEduR commented on June 5, 2024

It really works, I'm feeling a noob 'cause didn't think about this way.
Valeu, NewZeek.

But, as this 'create()' is an asynchronous function, I'd need to load it only when it has been already generated, and this function only finishes when QR Code from terminal was scanned. Do you have any simple idea to solve this?

from sulla.

NewZeek avatar NewZeek commented on June 5, 2024

The terminal and file QR are the same. When you read the html file in the browser, this terminal function automatically terminates. As sulla is a browser automation, it works as whatsapp web application and who informs that the qr has been read is the whatsapp app from smartphone.

In your application, create an ajax function that reads the qr file in time Interval e create a element tag < img /> when the server return the value.

Sorry my english

from sulla.

yodaheis avatar yodaheis commented on June 5, 2024

Ola pessoas,
What will be really cool is if we could take a snapshot, export a pdf and email it. I will give a shot at adding this feature.

from sulla.

rfscheidt avatar rfscheidt commented on June 5, 2024

does anyone has one sample?

from sulla.

danielcardeenas avatar danielcardeenas commented on June 5, 2024

When calling create() method you can attach a callback for it

const fs = require('fs');

// Second create() parameter is the QR callback
sulla.create('session-marketing', (qrCode) => {
  exportQR(qrCode, 'marketing-qr.png');
});

// Writes QR in specified path
function exportQR(qrCode, path) {
  qrCode = qrCode.replace('data:image/png;base64,', '');
  const imageBuffer = Buffer.from(qrCode, 'base64');

  // Creates 'marketing-qr.png' file
  fs.writeFileSync(path, imageBuffer);
}

from sulla.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.