Saturday, April 15, 2017

PHP read JSON file from remote URL

I've got this issue, PHP and Laravel. I'm trying to read a JSON file from remote ULR:

https://services.realestate.com.au/services/listings/search?query={"channel":"buy","filters":{"propertyType":["house"],"surroundingSuburbs":"False","excludeTier2":"true","geoPrecision":"address","localities":[{"searchLocation":"Blacktown, NSW 2148"}]},"pageSize":"100"}

I used the code:

$re_url = 'https://services.realestate.com.au/services/listings/search?query={"channel":"buy","filters":{"propertyType":["house"],"surroundingSuburbs":"False","excludeTier2":"true","geoPrecision":"address","localities":[{"searchLocation":"Blacktown, NSW 2148"}]},"pageSize":"100"}';

$ch = curl_init($re_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$re_str = curl_exec($ch);
curl_close($ch);
$re_list = json_decode($re_str);

It kept receiving Error "An error occurred while processing your request. Reference #30.96464868.1492255689.1829cf2"

I tried url with "https://google.com.au", which worked ok, so it looks like the URL encode issue. But I'm not sure.

Can anyone help, or had the same issues?

Thanks



via H.H

Advertisement