0

Im new using JSON and im trying to display url datas on my website. The code below is what i have tried but i cant.

I have reviewed other similar questions here but i didn't found any option to resolve this problem

<?php
$url ='https://test/link/thisurl';
$auth = base64_encode("username:password");
$context = stream_context_create([
    'http' => ['header' => "Authorization: Basic $auth"]
]);


$data = file_get_contents($url, false, $context);
$characters = json_decode($data);

echo $characters[0]->First;
echo $characters[0]->Last;
//json datas from link;

{
    "Persons": [
      {
        "First": "John",
        "Last": "Smith",
        "Number": 5586
      },
      {
        "First": "Andy",
        "Last": "Prill",
        "Number": 5589
      },
      {
        "First": "Jonathan",
        "Last": "Alex",
        "Number": 5585
      }
      ]

    }



?>
Jack
  • 11
  • 2

0 Answers0