I have an API that requires HTTP/Request2.php.
( Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
can I use CURL instead , is there is any way not to use this Component ?
here is the API code
<?php
require_once 'HTTP/Request2.php';
$request = new Http_Request2('http://ww');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>