Search code examples
phpjsontypeform

Reading JSON from HTTP POST using PHP (Typeform)


I'm having trouble reading JSON data (using PHP) that's coming in from a webhook (Typeform.)

I've tried the solution provided Here but I'm still getting a null array. My code is exactly the same as the example shown in the link (although I'm not accessing particular arrays, I just want to read the data.) All my test deliveries are returning 200, so I'm just a bit stuck.

$data = json_decode(file_get_contents('php://input'));

var_dump($data);

Solution

  • TypeForm runs the page, They'll get the var_dump response...

    When you run the page, you haven't posted anything so $data is empty, therefore null

    Try saving $data to a file, then when TypeForm POSTS to it, You can see what the POST contents were, in that file

    file_put_contents("webhookData.txt",$data, FILE_APPEND);