I want to get the UK region based on the postcode given using PHP. I have written as $ch = curl_init();
$post="PR3 0SG";
curl_setopt($ch,CURLOPT_URL, "https://api.postcodes.io/postcodes/$post");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "limit=1");
$buffer = curl_exec($ch);
if(empty ($buffer))
{
echo " buffer is empty ";
}
else
{
echo $buffer;
}
curl_close($ch);
I get "buffer is empty" message. What's wrong with this! Is there any other way or script to get UK regions using postcode? I possible please provide.