nguyenary / QRCodeMonkey

A library using PHP to generate QRCode from https://www.qrcode-monkey.com free
https://packagist.org/packages/nguyenary/qr-code-monkey
MIT License
77 stars 19 forks source link

WiFi QR Code #18

Open stemo40 opened 2 weeks ago

stemo40 commented 2 weeks ago

Hi,

This is a wonderful system with great results. Thank you!

The problem I am having is when using this class to generate a WiFi QR code. The result doesn't work because the password is missing. I used the below code:

$ssid = 'My-Guest-Wifi';
$auth = 'WPA';
$pass = 'APassWord';
$qrcode = new QRCode('WIFI:S:'.$ssid.';T:'.$auth.';P:'.$pass.';;');
$qrcode->create('tmp/atest.png');

The result I got was this: image

However, when I do a straight cURL Post call to the API, the result includes the password and works perfectly. Here's the post fields included in the cURL call: {"data":"WIFI:S:My-Guest-Wifi;T:WPA;P:APassWord;","size":600,"download":true}

So, am I doing something wrong in the code? There are no examples here on how to do WiFi QR codes, so I had to look at the how it was done on the qr-code-monkey website by looking at their JS file. But, since it works using cURL, I am guessing that there might be something happing with this class.

Any help is appreciated. Steve

stemo40 commented 2 weeks ago

Ok,

So, I think I know what is happening. Instead of: $qrcode = new QRCode('WIFI:S:'.$ssid.';T:'.$auth.';P:'.$pass.';;'); I changed it to:

$data = "WIFI:S:$ssid;T:$auth;P:$pass;";
$qrcode = new QRCode($data);

And it worked! So, I think the key is to use double quotes instead of separating variables with single quotes.

So, problem solved. Again, thanks for a great class! Steve