S
S
SpeakeazyYT12019-09-08 12:54:26
PHP
SpeakeazyYT1, 2019-09-08 12:54:26

Why am I not getting a JSON response when I send a GET request using PHP?

Good afternoon! There is such a site with ads - https://kolesa.kz/a/show/96337478
If you enter such a GET request at the following address using JS/JQuery.

$.get('https://kolesa.kz/a/ajaxPhones/?id=96337478', function(t) {
     console.log(t.data.model);
})

Then I get a JSON response:
evD1TJtkDWw.jpg
But how do I now send a GET request using PHP and get the same response, only not using JQuery?
I tried to do like this:
5HRi06kE3KI.jpg
function getPhones($id) {
  $ch = curl_init('https://kolesa.kz/a/ajaxPhones/?id='.$id);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_HEADER, false);
  $html = curl_exec($ch);
  curl_close($ch);
   
  return json_decode($html);
}

but got empty.
If I send a GET request using javascript, I get the following Header:
TAB2e88ji0M.jpg
F0JAL3OEi60.jpg
How can I correctly send a GET request to get the data I need?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Randewoo, 2019-09-08
@Randewoo

Duck, as it were, 404, JSON does not smell here
5d74d31702569211086623.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question