Download a QR
Download the code of the sendget
function defined in the file sendhttp.php.
Copy the file in the space of your application.
NOTE: See the page Call the service API for a description of the sendget
function.
URL
https://signmii.com/api/getqr?login=&password=&signmii=&fg=&bg=&quality=&size=
login | Your identification code. |
---|---|
password | Your password. |
signmii | The signmii to encode in the QR. |
fg | Foreground color of the QR. |
bg | Background color of the QR. |
quality | Quality level of the QR. |
size | Size of the QR. |
signmii
is the string of characters returned by the getsignmii action.
fg
and bg
have the standard format RRGGBB in hexadecimal with or without a # (HASHMARK).
quality
defines the error percentage of the reproduction of the QR.
The higher the correction rate is, the bigger is the minimum size of the QR:
L | 7% | 65px |
M | 15% | 77px |
Q | 25% | 85px |
H | 33% | 97px |
size
multiplies the minimum size of the QR by a value between 1 and 10.
EXAMPLE: A QR for a signmi of quality M and of size 2 will be 154 pixels by 154 pixels.
IMPORTANT: QR code readers work better if the contrast between the color of the QR and its background is strong. Check with a smartphone.
Add the file getqr.php with the following content:
- require_once 'sendhttp.php';
Loads the code of the sendget
function provided by iZend.
- function getqr($login, $password, $signmii, $fg='#000000', $bg='#ffffff', $quality='M', $size='1') {
Defines the function getqr
.
$login
is your identification code. $password
is your password.
$signmii
contains the text of the signmii which will be encoded in the QR.
$fg
gives the color of the QR, black by default.
$bg
gives the background color of the QR, white by default.
$quality
gives the quality level of the QR, M by default.
$size
gives the size of the QR, 1 by default.
- $curl = 'https://signmii.com/api/getqr';
- $args = array(
- 'login' => $login,
- 'password' => $password,
- 'signmii' => $signmii,
- 'fg' => $fg,
- 'bg' => $bg,
- 'quality' => $quality,
- 'size' => $size,
- );
Sets $curl
to the URL of the getqr action.
Fills the array $args
with the parameters of the getqr action.
NOTE: Replace http
by https
in the URL to encrypt the communication.
- $response=sendget($curl, $args);
Sends the HTTP request with sendget
.
- if (!$response or $response[0] != 200) {
- return false;
- }
If $response
is false
, the server is unreachable.
If $response[0]
doesn't contain the HTTP return code 200 Ok, an execution error has occurred.
In case of error, getqr
returns false.
- $r = $response[1]['Content-Disposition'];
- $filename=substr($r, strpos($r, 'filename=')+9);
Extracts the file name from the header of the response.
- $data=$response[2];
- file_put_contents($filename, $data);
Writes the body of the response, the binary representation of the PNG image of the QR code, in the current folder.
- return $filename;
- }
Returns the file name.
EXAMPLE
Assuming you have saved the files sendhttp.php and getqr.php in the current directory, run PHP in interactive mode, load the getqr
function and call it with your identification code, your password and text of a signmii in argument:
$ php -a
php > $signmii='uIWPRlfPaB8VgkTHIg8IoTe72WtTLgL_vGoWjY8PfM9fFjwXb8LmvMsMGKVUUTvJOy-z536BC-GMCOaDDdHhcWqGEYyUlXULwwGBXQL7drGnnbTa0H4bCD1YME6H9q7xIdMqlD9pIS-CIAsAo1SYguOhHP9bBlZ_7vk91gmKmxJQi6ril_UlvUmvmjJbUSnoyvDBLPcOWTa0hPDiPKnLifaimHHzkKfLtD9Ck2DAam9G3q3ME0zayVOTTlFdyPsOwvM6SvOMqAi-iBV40Bg5Ky4wKJztDMiCCBCdx3k-jvMfVtZM61MoIDNaICeI59UYE-HL8cPX3CcRphXYdFmRHg';
php > require_once 'getqr.php';
php > echo getqr('abcdef', 'ABCDEF', $signmii);
signmii.png
The image of the QR is in the file signmii.png.
Try a color and a larger size:
php > getqr('abcdef', 'ABCDEF', $signmii, '#aa0000', '#000000', 'L', 8);
php > quit
Comments