How to get a value from a json

I have to get the “media_id” value from the json that is sent to me from facebook, I tried everything but I can’t.
how can I do?

<?php


$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];

// Set this Verify Token Value on my Facebook App
if ($verify_token === 'token') {

echo $challenge;

$readjson = file_get_contents('php://input');

//Decode JSON
 $data = json_decode($readjson, true);

//try get media_id value

 print_r($data[entry][changes][value][media_id]);

 //response code 200 - ok
 header('HTTP/1.0 200 OK');

} else {
  header('HTTP/1.0 401 Unauthorized');
}




 ?>

this is the json that is sent to me, I can’t get the value “media_id”

{
    "object": "instagram",
    "entry": [{
        "id": "0",
        "time": 1573295665,
        "changes": [{
            "field": "story_insights",
            "value": {
                "media_id": "17887498072083520",
                "impressions": 444,
                "reach": 44,
                "taps_forward": 4,
                "taps_back": 3,
                "exits": 3,
                "replies": 0
            }
        }]
    }]
}

I thank you for the help you give me

Leave a Reply

Your email address will not be published. Required fields are marked *