-1

My api json

{"success":true,"result":{"id":"1017fw436","title":"Leading with NLP","author":"David","url":"abc.com","image":"/abc.img","info":{"pages":"258 Pages","year":"2001","size":"2.74 MB","downloads":"151,185 Downloads","language":"English"},"url_url":"https://drive.google.com/file/d/1GDA9N9SQLHdXBKih8c_GEwcUL"}}

I used

    <?php $json_url = "my link api";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
echo $data['id'];
?>

But it doesn't work

  • 5
    If you mean that the id is not being echo'ed then you need to use the instruction $data['result']['id'] –  Dec 03 '19 at 04:19
  • Or sometimes, maybe your PHP server can't make a correct request to your API (mostly because of https client verify). Please have a look at your error log for more detail. – The Anh Nguyen Dec 03 '19 at 06:14

1 Answers1

0

Please check Link

try this line of code:

file_get_contents("http://example.com", false, ['ignore_errors' => true]);
var_dump($http_response_header);
Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53