PHP code example of me-qr / me-qr-php-sdk

1. Go to this page and download the library: Download me-qr/me-qr-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

me-qr / me-qr-php-sdk example snippets




eQR\MEQRClient;
use MeQR\QROptions;

$client = new MEQRClient('YOUR_API_TOKEN');

// URL QR code → save to file
$result = $client->createLink('https://me-qr.com');
$result->save('qr.png');

// Styled SVG
$options = new QROptions(size: 500, foregroundColor: '#2563eb', errorCorrection: 'H');
$result = $client->createLink('https://me-qr.com', format: 'svg', options: $options);
echo $result->toDataUrl(); // data:image/svg+xml;base64,...

$result = $client->createLink('https://example.com');
$result->save('link.png');

use MeQR\MEQRClient;

$result = $client->createWifi(
    ssid: 'MyNetwork',
    password: 'secret',
    encryption: MEQRClient::WIFI_ENC_WPA, // 'wpa/wpa2' | 'wpa3' | 'wep' | 'none' | 'raw'
);
$result->save('wifi.png');

$result = $client->createVCard(
    name: 'Alex',
    phones: [['phone' => '+1234567890', 'type' => 0]], // type: 0=general, 1=work
    emails: [['email' => '[email protected]', 'type' => 0]], // type: 0=general, 1=corporate
    organization: 'ACME Corp',
    lastName: 'Smith',
);
$result->save('vcard.png');

$result = $client->createEmail(
    email: '[email protected]',
    subject: 'Hello',
    body: 'Message body',
);
$result->save('email.png');

$result = $client->createText('Hello, World!');
$result->save('text.png');

use MeQR\MEQRClient;

$result = $client->create(
    qrType: MEQRClient::TYPE_WIFI,
    title: 'Office Wi-Fi',
    qrFieldsData: ['ssid' => 'Corp', 'password' => 'pass', 'encryption' => 'wpa/wpa2'],
    format: 'svg',
);

use MeQR\MEQRException;

try {
    $result = $client->createLink('https://example.com');
} catch (MEQRException $e) {
    echo "Error {$e->getStatusCode()}: {$e->getMessage()}";
    echo $e->getResponseBody();
}
bash
php example.php