API Documentation
Integration Examples
Below are practical examples for integrating the QR Code Generator API into different platforms and programming languages.
JavaScript (Fetch API)
Generate a QR code from a web application:
// Generate QR code
fetch('/api/qr/create.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
data: 'Hello World',
size: 300,
format: 'png'
})
})
.then(response => response.json())
.then(data => {
if (data.qr_code_url) {
// Use the URL to display the QR code
document.getElementById('qr-image').src = data.qr_code_url;
}
})
.catch(error => {
console.error('Error:', error);
});
cURL
Command-line examples for testing and automation:
# Generate QR code
curl -X POST "https://rcor.hu/api/qr/create.php" \
-H "Content-Type: application/json" \
-d '{"data":"Hello World","size":300,"format":"png"}'
# Read QR code
curl -X POST "https://rcor.hu/api/qr/read.php" \
-F "image=@qr_code.png"
PHP
Server-side integration example:
// Generate QR code
$data = [
'data' => 'Hello World',
'size' => 300,
'format' => 'png'
];
$ch = curl_init('https://example.com/api/qr/create.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
$result = json_decode($response, true);
curl_close($ch);
if (isset($result['qr_code_url'])) {
echo "QR Code URL: " . $result['qr_code_url'];
}
Note: For production use, install PHP QR code libraries via Composer:
composer require endroid/qr-code for generation and
composer require khanamiryan/qrcode-detector-decoder for decoding.