【问题标题】:Dropbox Webhooks contains no post dataDropbox Webhooks 不包含发布数据
【发布时间】:2023-03-24 22:57:01
【问题描述】:

我正在尝试使用 Dropbox 的 Webhooks 界面跟踪用户的文件更改。我希望调用包含 POST 数据,但似乎没有 POST 数据(或 GET 数据,就此而言)。这是我的 PHP 代码,其中if 部分用于 Dropbox 验证 webhook,else 部分将 $_POST$_GET 变量保存到文件中。

<?php
if( isset( $_GET['challenge'] ) ) {
    echo $_GET['challenge'];
} else {
    $output = print_r($_POST, true);
    file_put_contents('file.txt', $output, FILE_APPEND );
    $output = print_r($_GET, true);
    file_put_contents('file.txt', $output, FILE_APPEND );
}
?>

过了一会儿,file.txt 填满了这个:

Array
(
)
Array
(
)

【问题讨论】:

    标签: php dropbox webhooks


    【解决方案1】:

    按照this answer 的相关问题,您需要像这样获取 JSON 数据:

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

    或者,因为它是 JSON:

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

    【讨论】:

      猜你喜欢
      • 2013-08-25
      • 1970-01-01
      • 2017-08-26
      • 1970-01-01
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      • 2015-05-01
      • 2015-12-09
      相关资源
      最近更新 更多