从Hubspot Webhook捕获JSON数据 [英] Catching json data from hubspot webhook

查看:271
本文介绍了从Hubspot Webhook捕获JSON数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的一生,我无法弄清自己的缺失.我正在使用HubSpot,并且具有工作流程设置以使用发布到我拥有的脚本的Web挂钩.当我设置网址以将webhook数据捕获到requestb.in时,它传递了数据,并且可以看到原始的json数据.但是,当我尝试用自己的代码捕获它并将其写入文本文件时,我什么也没得到.

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.

我尝试过类似的事情:

$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);

无论做什么,我都无法捕获从Webhook发布的数据.

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

这是我的问题.在正常过程中,当从api发布json数据时, 我是否正确要求json数据的变量"通常是消息" (例如:$ _ POST ['message'])?

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'])?

我想问一个关于我丢失或做错什么的指针,这将使我无法捕获这些数据.我真的开始以为是HubSpot,而不是我,但我需要先确认一下.

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.

谢谢

推荐答案

我很幸运在顶部使用以下代码: $ _POST = file_get_contents('php://input');

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

这篇关于从Hubspot Webhook捕获JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆