1. Go to this page and download the library: Download mjydh/httpclient 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/ */
// Http client
use MJYDH\HttpClientBundle\Service\HttpClient;
use MJYDH\HttpClientBundle\Exception\HttpException;
use MJYDH\HttpClientBundle\Exception\CatchExceptions;
try
{
$http = new HttpClient();
$http->setAuth($user, $pass); //En caso que sea por BASIC AUTH
$http->setHeaderApiKey($keyValue, "apikey"); //En case que el auto sea por apikey
//Se agrega al array todos los http_codes que se quieran recortar cuando se llama al Execute();
$http->setHttpCodeResponses(array(200));
//Se agregan todos los http_codes que tiran un CatchExceptions
$http->setCatchExceptions(array(502=> new CatchExceptions("Titulo - Error 502", "Mensaje de error"),
0=> new CatchExceptions("Titulo - Error 502", "Mensaje de error")));
//Ejecuta el http request y retorna un HttpResult
$result = $http->Execute('GET', $url);
}
} catch (CatchExceptions $cehttp) {
return $this->showError($cehttp->getMessage(), $cehttp->getTitle());
}catch (HttpException $ehttp){
return $this->showError($ehttp->getMessage(), $ehttp->getTitle());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.