PHP code example of apihub-cdc / trayectorias-laborales-client-php

1. Go to this page and download the library: Download apihub-cdc/trayectorias-laborales-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 / trayectorias-laborales-client-php example snippets


$password = getenv('KEY_PASSWORD');
$this->signer = new \lae\Client\Interceptor\KeyHandler(
    "/example/route/keypair.p12",
    "/example/route/cdc_cert.pem",
    $password
);

public function setUp()
{
    $this->x_api_key = "your_api_key";
    $this->basic_auth_username = "your-basic-auth-username";
    $this->basic_auth_password = "your-basic-auth-password";
    $this->url_API = "the_url";
    //..code
}  

public function testConsultarTrayectorias()
{
    $request = new Busqueda();
    $persona = new PersonaConsulta();
    $domicilio = new DomicilioConsulta();
    $catalogoSexoPersona = new CatalogoSexoPersona();

    $persona->setPrimerNombre("Juan");
    $persona->setApellidoPaterno("Pruebauno");
    $persona->setApellidoMaterno("Pruebauno");
    $persona->setFechaNacimiento("1986-12-01");
    $persona->setSexo($catalogoSexoPersona::M);
    
    $domicilio->setDireccion("TORNO 301 EL ROSARIO");
    $domicilio->setColonia("PEDREGAL DE SANTO DOMINGO");
    $domicilio->setCp("02100");
    
    $request->setClaveEmpresaConsulta("2007310044");
    $request->setFolioConsultaEmpleador("2620100");
    $request->setProductoRequerido(4);
    $request->setPuestoSolicitado("Vendedor");
    $request->setPersona($persona);
    $request->setDomicilio($domicilio);  

    try {
        $result = $this->apiInstance->consultarTrayectorias($this->x_api_key, $request);
        print_r($result);
        
        if($this->apiInstance->getStatusCode() == 200){
            print_r($result);
        }

        $this->assertTrue($this->apiInstance->getStatusCode() == 200);
    } catch (ApiException $e) {

        if($e->getCode() !== 204){
            echo ' code. Exception when calling ApiTest->consultarTrayectorias: ', $e->getResponseBody(), 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
sh
export KEY_PASSWORD=your_password
sh
export PRIVATE_KEY_FILE=pri_key.pem
export CERTIFICATE_FILE=certificate.pem
export SUBJECT=/C=MX/ST=MX/L=MX/O=CDC/CN=CDC
export PKCS12_FILE=keypair.p12
export ALIAS=circulo_de_credito