This API make scanning device outside fonnte possible.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.fonnte.com/qr',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'Authorization: TOKEN'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
If you prefer to see on postman, see here.
TOKEN must be filled by your own token. See how to get token.
If your device is not connected to fonnte yet, you'll get this response
{
"status": true,
"url": "iVBORw0KGgoAAAANSUhEUgAAARQAAAEUCAYAA..."
}
Then you can use the url from the response to show in image tag src.
<img src="data:image/png;base64,<?= $qr?>">
For example using php curl :
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.fonnte.com/qr',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'Authorization: TOKEN'
),
));
$response = curl_exec($curl);
curl_close($curl);
$res = json_decode($response,true);
if(isset($res['url'])){
$qr = $res['url'];
?>
<img src="data:image/png;base64,<?= $qr ?>">
<?php
}
?>
If your device is already connected, the response is
{
"reason": "device already connect",
"status": false
}
If somehow your token is invalid
{
"reason": "token invalid",
"status": false
}