1. Go to this page and download the library: Download apihub-cdc/pld-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-client-php example snippets
/**
* Esto es parte del setUp() de las pruebas unitarias.
*/
$password = getenv('KEY_PASSWORD');
$this->signer = new Signer\Manager\Interceptor\KeyHandler(
"/example/route/keypair.p12",
"/example/route/cdc_cert.pem",
$password
);
$config = new \pld\mx\Client\Configuration();
$config->setHost('the_url');
public function setUp()
{
$password = getenv('KEY_PASSWORD');
$this->signer = new Signer\Manager\Interceptor\KeyHandler(null, null, $password);
$events = new Signer\Manager\Interceptor\MiddlewareEvents($this->signer);
$handler = \GuzzleHttp\HandlerStack::create();
$handler->push($events->add_signature_header('x-signature'));
$handler->push($events->verify_signature_header('x-signature'));
$config = new \pld\mx\Client\Configuration();
$config->setHost('the_url');
$client = new \GuzzleHttp\Client(['handler' => $handler]);
$this->apiInstance = new \pld\mx\Client\Api\PLDApi($client, $config);
}
/**
* Este es el método que se será ejecutado en la prueba ubicado en path/to/repository/test/Api/SegmentadorApiTest.php
*/
public function testGetPLD()
{
$x_api_key = "your_api_key";
$username = "your_username";
$password = "your_password";
$body = new Peticion();
$body->setNombres("JUAN");
$body->setApellidoPaterno("PRUEBA");
$body->setApellidoMaterno("CUATRO");
try {
$result = $this->apiInstance->getPLD($x_api_key, $username, $password, $body);
$this->assertTrue($result->getFolioConsulta()!==null);
$this->signer->close();
print_r($result);
} catch (Exception | ApiException $e) {
echo 'Exception when calling PLDApi->getPLD: ', $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