Samson
Samson

Reputation: 75

Trello webhook contains empty array in php

I've successfully created multiple webhooks within Trello using PHP, but each time a 'hook' comes in (triggering exactly as it should), it contains an empty array and no data.

I've simplified my PHP in an attempt to remove potential issues to where my code is the following:

<?php
/////PRINT////
$req_dump = print_r($_REQUEST, TRUE);$fp = fopen('webHookTest.txt', 
'w+');fwrite($fp, $req_dump);fclose($fp);
?>

Using $_POST returns the same. Has anyone else seen this issue? Why on earth would I get an empty array in the request every time.

Thanks for the help.

Upvotes: 1

Views: 333

Answers (1)

Samson
Samson

Reputation: 75

I discovered the solution on This Post.

''I had to use this:

 $json = file_get_contents('php://input');
 $action = json_decode($json, true);

As far as I understand the json request is not automaticly split into the $_POST. Thus you have to use the input itself.

The true-parameter in json_decode is needed to get an associative array. Without it I only got an empty array.''

Upvotes: 1

Related Questions