Requisição de QR Code

Método expireqrcode:

<?php

require __DIR__ . '/vendor/autoload.php';

use ZapMeTeam\Api\ZapMeApi;

$zapme = (new ZapMeApi)
        ->setApi('API')
        ->setSecret('CHAVE_SECRETA');

// utilizando o método requestQRCode
$zapme->requestQRCode()->getResult();

Exemplo de retorno deste método:

{
        "result": "success",
        "date": "2021-10-20 13:11:55",
        "status": 200,
        "status_result": "qrcode_requested",
        "image": "iVBORw0KGgoAAAANSUhEUgAAAQ4AAAEOCAIAAAD3027yAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MzQ5MTUzOUFBNUY3MTFFQUE5RjJCMTNBODExNjYxNzQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MzQ5MTUzOTlBNUY3MTFFQUE5RjJCMTNBODEx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sw3QFGH9dmeGcpIh8GqACAVAKQCgFQAkApA0WJa2JIXmN2CWKaXUFmewpw/VgUABwwAqQAgFQCkAoBUAEqbPoZ92Z63zeVaN8gXlg8bZrXRMzL1jFUBQCoASAUAqQAgFYCipU9aqXuzpDKDcxo5WEsHuSQvb4RLdwIWqwKAAwaAVACQCgBSAUAqAKVNn8IvIm+XLHmiLanMcU/AqgAgFQCkAoBUAJAKQNFSBDNgzHcVNdEmMLO05LE3/QqrAoBUAJAKAFIBQCoASAWgtElvsjgv87a8hLLEsJk+7s3rEyJPNPNTRAA4YABIBQCpACAVgBLFNANWID/PDUWNzeyW5WRUZpNhVQBwwACQCgBSASgxqYwfR3UAhEvl2Vl3oxaAIOKJRIJaACBWAUAqADnk/wUYAHR6qmWa6CL1AAAAAElFTkSuQmCC",
        "messages": "requisicao de qrcode em andamento"
}

Explicação dos Parâmetros Obrigatórios da Requisição

  • API

sua API obtida na ZapMe

  • CHAVE_SECRETA

sua chave secreta obtida na ZapMe

  • requestQRCode

o método do SDK a ser utilizado nesta ação, neste caso: requestqrcode

Mecânica de Geração do QR Code

Para usufruir da geração de QR Code via API será necessário que a cada cinco (5) segundos seja emitido uma nova requisição (requestQRCode) para a API para que as imagens do QR Code, se geradas, sejam retornadas permitindo a a continuação do processo de autenticação. Isso ocorre porque cada QR Code possui um tempo de validade e enquanto o QR Code não for gerado uma imagem como o exemplo abaixo será gerado em seu lugar.

Dica

Uma boa pratica é enviar o usuário que pretende escanear o QR Code para uma página, e nesta página definir o intervalo de atualização da página a cada cinto (5) segundos (via JavaScript, por exemplo), dessa forma a cada cinco (5) segundos a API fará uma requisição até obter o QR Code para ser escaneado.

Enquanto o QR Code não for gerado essa imagem será exibida:

../../_images/13.png

Depois que o QR Code for gerado, ele irá aparecer:

../../_images/22.png
Observação:

A imagem do QR Code é retornada no parametro image em formato base64. Você precisa fazer com que a imagem gerada e retornada no parametro image entre em uma tag img neste formato:

<img src="data:image/png;base64,{$hash_aqui}" />

Importante

Se ao invés do QR Code for exibido uma imagem de erro em algum momento, contate o suporte técnico da ZapMe imediatamente para que o erro seja analisado e corrigido o quanto antes possível.