Plaid webhooks的PHP脚本

时间:2016-02-18 16:38:47

标签: php webhooks plaid

我已经设置了一个帐户来试用,其API中最有趣的部分之一是webhooks。但是,我还没有找到如何使用PHP脚本“捕获”webhook的参考。我想它就像是:

<?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为空。

1 个答案:

答案 0 :(得分:2)

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

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