PHP code example of apihub-cdc / pld-naturales-client-php
1. Go to this page and download the library: Download apihub-cdc/pld-naturales-client-php 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/ */
apihub-cdc / pld-naturales-client-php example snippets
/**
* Esto es parte del setUp() de las pruebas unitarias.
*/
$password = getenv('KEY_PASSWORD');
$this->signer = new \PLDNaturales\Client\Interceptor\KeyHandler(
"/example/route/keypair.p12",
"/example/route/cdc_cert.pem",
$password
);
public function setUp()
{
$password = getenv('KEY_PASSWORD');
$this->signer = new \PLDNaturales\Client\Interceptor\KeyHandler(null, null, $password);
$events = new \PLDNaturales\Client\Interceptor\MiddlewareEvents($this->signer);
$handler = \GuzzleHttp\HandlerStack::create();
$handler->push($events->add_signature_header('x-signature'));
$handler->push($events->verify_signature_header('x-signature'));
$client = new \GuzzleHttp\Client(['handler' => $handler, 'verify' => false]);
$config = new \PLDNaturales\Client\Configuration();
$config->setHost('the_url');
$this->apiInstance = new \PLDNaturales\Client\Api\PLDNaturalesApi($client,$config);
}
/**
* Este es el método que se será ejecutado en la prueba ubicado en path/to/repository/test/Api/ApiTest.php
*/
public function testPldNaturales()
{
$x_api_key = "your_api_key";
$username = "your_username";
$password = "your_password";
$request = new \PLDNaturales\Client\Model\Peticion();
$request->setFolio("123456789");
$request->setTipoDocumento("1");
$request->setNumeroDocumento("00000088");
$request->setNombre("NOMBRE");
$request->setSegundoNombre("SEGUNDONOMBRE");
$request->setApellidoPaterno("PATERNO");
$request->setApellidoMaterno("MATERNO");
try {
$result = $this->apiInstance->pld($x_api_key, $username, $password, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ApiTest->pld: ', $e->getMessage(), PHP_EOL;
}
}
sh
#ejemplo con php en versión 7.3 para otra versión colocar php{version}-curl
apt-get install php7.3-curl
apt-get install php7.3-mbstring