Catching json data from hubspot webhook

断了今生、忘了曾经 提交于 2019-12-11 08:26:06

问题


For the life of me I can't figure out what I am missing. I am using HubSpot and have a workflow setup to use a web hook that posts to a script that I have. When I set the url to capture the webhook data onto requestb.in it passed the data and I can see the raw json data. But when I try to capture it with my own code and write it to a text file, I get absolutely nothing.

I have tried things like:

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, $_POST);
fwrite($fh, $_GET);
fwrite($fh, $_REQUEST);
fwrite($fh, $_POST['message']);
fwrite($fh, $_GET['message']);

fclose($fh);

And no matter what I do - I can't capture the data being posted from the webhook.

So here's my question. In a normal procedure, when json data is posted from an api, am I correct in asking that the "variable" of the json data is usually "message" (For example: $_POST['message'])?

And I would kindly ask a pointer as to what I am missing or doing wrong that won't allow me to capture this data. I am really beginning to think it's HubSpot and not me, but I need to confirm that first.

Thanks


回答1:


I had luck with using this code at the top: $_POST = file_get_contents('php://input');



来源:https://stackoverflow.com/questions/25984428/catching-json-data-from-hubspot-webhook

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!