PHP Plaid webhook 脚本

PHP script for Plaid webhooks

我已经建立了一个帐户来试用,他们 API 中最有趣的部分之一是 webhooks。但是,我还没有找到如何使用 PHP 脚本 'catch' webhooks 的参考资料。我想它是这样的:

<?php
//pseudo-ish code
$webhook = $_POST['webhook'];
$json = json_decode($webhook, true);

// code to save webhook data

有人有什么想法吗? Here is the link to their API

根据评论,我试过:

<?php
$result = var_export($_POST, true);
$file = fopen("screenshots/test.txt","w");
echo fwrite($file, "testing:".$result);
fclose($file);
?>

所有结果都是一个文件,其中包含单词 "testing:array()",表明 $_POST 为空。

API 将负载作为请求正文中的 JSON 编码字符串发送。

$data = json_decode(trim(file_get_contents('php://input'), '"\''), true);