Skip to content

Instantly share code, notes, and snippets.

Created June 5, 2014 17:14
Show Gist options
  • Save anonymous/82b78ceb1ea8415df375 to your computer and use it in GitHub Desktop.
Save anonymous/82b78ceb1ea8415df375 to your computer and use it in GitHub Desktop.
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
$request = array(
'Credentials' => array(
'ApiKey' => "API_KEY"
),
'Customer' => array(
'Reference' => "SESSIONID"
),
'Parameters' => array(
'Term' => "36",
'Deposit' => "10",
'DepositType' => "Percentage",
'AnnualMileage' => "10000"
),
'VehicleRequests' => array(
array(
'Id' => '1234',
'Vehicle' => array(
'CashPrice' => "10000",
'IsNew' => "true",
'Identifier' => "CAP_ID",
'IdentifierType' => "CapShortCode",
'Type' => "Car",
'StockId' => "12345",
'ImageUrl' => "http://notworking.com/1234.jpg",
'DealerVehicleUrl' => "http://notworking.com/1234/",
'IsVatQualifying' => "true"
)
)
)
);
$data = json_encode($request);
echo($data);
print "\r\n---------------------------------------------------------------------------------\r\n";
$options = array(
'http' => array(
'header' => array(
"Referer: http://localhost",
"Content-type: application/json",
"Accept: application/json",
sprintf('Content-Length: %d', strlen($data))
),
'method' => 'POST',
'content' => $data,
)
);
$url = 'https://demoservices.codeweavers.net/public/v2/JsonFinance/Calculate';
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
print_r($response);
print "\r\n---------------------------------------------------------------------------------\r\n";
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "The request took $time seconds\n\n\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment