- stream_context_create: documentation ( source)
- stream_get_contents: documentation ( source)
- http_build_query: documentation ( source)
- fopen: documentation ( source)
<?php
$postdata = http_build_query(
array(
'format' => 'csv',
'data' => '3GNDA13D76S000000;5XYKT3A12CG000000'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'content' => $postdata
)
);
$apiURL = "https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVINValuesBatch/";
$context = stream_context_create($opts);
$fp = fopen($apiURL, 'rb', false, $context);
if(!$fp)
{
echo "in first if";
}
$response = @stream_get_contents($fp);
if($response == false)
{
echo "in second if";
}
echo $response;
?>