【问题标题】:I do not receive any payload from trello when my webhook is triggered当我的 webhook 被触发时,我没有从 trello 收到任何有效负载
【发布时间】:2020-03-07 14:09:30
【问题描述】:

我在 trello 中为列表创建了一个 webhook:

curl -X POST -H "Content-Type: application/json" \
https://api.trello.com/1/tokens/$TRELLO_TOKEN/webhooks/ \
-d '{
  "key": "$TRELLO_API_KEY",
  "callbackURL": "https://at.foobar.com/trello-whook.php",
  "idModel":"5d9511856b7586142414762b",
  "description": "My first webhook"  
}'

我得到的答案是:

{"id":"5dc9cded49bf251341c6d32c","description":"My first webhook","idModel":"5d9511856b7586142414762b","callbackURL":"https://at.foobar.com/trello-whook.php","active":true,"consecutiveFailures":0,"firstConsecutiveFailDate":null}%

当我在此列表中添加/删除卡片时,我的 webhook 会被触发。当我理解 documentation 正确时,我应该将带有 JSON 的 HTTP POST 发送到我的 webhook。但是我的日志文件中没有看到任何有效负载...

这是我的trello-webhook.php 代码:

<?php
ini_set( "log_errors", 1);
ini_set( "error_log", "/var/log/trello-scripts.log");
error_log(  "trello-whook was called" );
$output = print_r( $_POST, true );
error_log( $output );
?>

这是我的/var/log/trello-scripts.log 的输出:

[11-Nov-2019 21:25:54 UTC] trello-whook was called
[11-Nov-2019 21:25:54 UTC] Array
(
)

我哪里有误会?如何获取 trello JSON?

【问题讨论】:

  • 试试 print_r($_REQUEST) 看看是否有帮助
  • @PavelLint 与print_r($_REQUEST) 的结果相同:空的Array()

标签: php webhooks trello


【解决方案1】:

您应该能够通过以下方式获取有效负载:

$data = file_get_contents("php://input");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-12
    • 1970-01-01
    • 1970-01-01
    • 2020-04-24
    相关资源
    最近更新 更多