I thought I'm getting quite well with PHP/curl, but here I don't know what's all about?
[GET] https://www.olx.pl can be fetched with no problems, but I can't get JSON requesting: [GET] https://www.olx.pl/i2/ajax/ad/getcontact/?id=477486803&type=phone
In browser it's fine, in POSTMAN it's fine (all security options off).
The code I execute:
$urlForTel = "https://www.olx.pl/i2/ajax/ad/getcontact/?id=477486803&type=phone";
$headers = array(
'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0'
);
$ch = curl_init();
// curl_setopt($ch, CURLOPT_PROXY, $proxy_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $urlForTel);
$result=curl_exec($ch);
The code just stops and doesn't go forward... As you see I tried many different options (certs, proxy, with headers and without). However when you change e.g. last digit in ID in param (requesting non existing asset), it returns HTML correctly...
I tried
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
with cert downloaded and with/without useragent as well...
curl_error($ch)
to see if the request returns any errors.echo curl_error($ch)
aftercurl_exec
.