Can't view echoed output

Array
(
    [id] => 9794ea5d-9dc1-4b15-a798-fd0fa4ff6f4c
    [timestamp] => 2017-07-05T03:47:00.764Z
    [lang] => en
    [result] => Array
        (
            [source] => agent
            [resolvedQuery] => what is annual leave
            [speech] => 
            [action] => test
            [actionIncomplete] => 
            [parameters] => Array
                (
                    [allowance_type] => Array
                        (
                        )

                    [bonus_type] => Array
                        (
                        )

                    [salary_type] => Array
                        (
                        )

                    [leave_type] => Array
                        (
                            [0] => annual leave
                        )

                )

            [contexts] => Array
                (
                    [0] => Array
                        (
                            [name] => to-apply
                            [parameters] => Array
                                (
                                    [allowance_type] => Array
                                        (
                                        )

                                    [leave_type] => Array
                                        (
                                            [0] => annual leave
                                        )

                                    [bonus_type.original] => 
                                    [bonus_type] => Array
                                        (
                                        )

                                    [leave_type.original] => annual leave
                                    [allowance_type.original] => 
                                    [salary_type] => Array
                                        (
                                        )

                                    [salary_type.original] => 
                                )

                            [lifespan] => 5
                        )

                )

            [metadata] => Array
                (
                    [intentId] => e2bda510-2f4d-41b8-a80b-e11f148c804b
                    [webhookUsed] => true
                    [webhookForSlotFillingUsed] => false
                    [intentName] => description-definition-what
                )

            [fulfillment] => Array
                (
                    [speech] => 
                    [messages] => Array
                        (
                            [0] => Array
                                (
                                    [type] => 0
                                    [speech] => 
                                )

                        )

                )

            [score] => 1
        )

    [status] => Array
        (
            [code] => 200
            [errorType] => success
        )

    [sessionId] => 07a5acce-9587-4f06-b715-1c9106732109
)
      

Run codeHide result


Hi so I have this code where I am trying to create a webhook to call a json file from API.AI. It gets the data and stores in a new call to the JSON.php file, but im trying to display the data which it doesn't. Is it because the page doesn't automatically refresh or?

<?php

$data = json_decode(file_get_contents("php://input"), true);
file_put_contents("JSON.php", print_r($data, true));

echo $data['intentName'];

?>
      

Run codeHide result


+3


source to share


1 answer


So it should be $data['result']['metadata']['intentName'];

instead$data['intentName']



+1


source







All Articles