PHP code example of fawno / agencias

1. Go to this page and download the library: Download fawno/agencias 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/ */

    

fawno / agencias example snippets


use Fawno\Agencias\EFEClient;
use Fawno\Agencias\EFE\Format;
use Fawno\Agencias\EFE\FormatRequest;

$efe = EFEClient::create($_ENV['EFE_CLIENT_ID'], $_ENV['EFE_CLIENT_SECRET']);

$products = $efe->getProducts();
$content = $efe->getItemsInFormat(
    Format::TEXTO,
    format: FormatRequest::JSON,
);

$models = $efe->getModels();
$modelName = $models->data->models->first();
$modelValues = $efe->getModelData($modelName);

use Fawno\Agencias\EFE\Exception\ForbiddenException;
use Fawno\Agencias\EFE\Exception\NotFoundException;

try {
    $content = $efe->getItemsByProductId(1234);
} catch (NotFoundException) {
    // La consulta no devolvió contenido o sus parámetros no son válidos.
} catch (ForbiddenException) {
    // El producto no está contratado por este cliente.
}