简体   繁体   English

PHP中的hubspot webhook麻烦

[英]hubspot webhook trouble in PHP

I have been asked to deal with web hook concept. 我被要求处理网络挂钩概念。 I am very new to this concept and i will need your help. 我对这个概念很陌生,需要您的帮助。 I was asked to provide a URL to a company so they can send json data from their website. 我被要求提供一个公司的URL,以便他们可以从其网站发送json数据。

So far i found this : 到目前为止,我发现了这一点:

 //  Initiate curl
 $ch = curl_init();
 // Disable SSL verification
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 // Will return the response, if false it print the response
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 // Set the url
 curl_setopt($ch, CURLOPT_URL,$url);
 // Execute
 $result=curl_exec($ch);
 // Closing
 curl_close($ch);

 // Will dump a beauty json :3
 var_dump(json_decode($result, true));

so is URL same as this PHP file? URL是否与此PHP文件相同? I am really confused. 我真的很困惑。 Thank You 谢谢

It's hard to be sure from the info you are providing, but you are probably coming at this the wrong way around. 从提供的信息中很难确定,但是您可能会以错误的方式来解决。

You probably need to write a php script that will be the target of a webhook. 您可能需要编写一个将成为Webhook目标的php脚本。 Here is a post that should get you started: Catching json data from hubspot webhook 这是应该入门的帖子: 从hubspot webhook捕获json数据

Update: I have created an article to help with this 更新:我创建了一篇文章来帮助解决这个问题

You don't need to use curl for a HubSpot webhook, the webhook should trigger some kind of action on your server and receive posted data ready for massaging and manipulating. 您无需为HubSpot Webhook使用curl,该Webhook应该会触发服务器上的某种操作,并接收准备好进行按摩和处理的已发布数据。 A webhook could be, when a contact fills out a form or completes a specific action within HubSpot and you push that data to your custom script on a stand alone server. 当联系人填写表单或完成HubSpot中的特定操作并将您将数据推送到独立服务器上的自定义脚本时,Webhook可能就是这样。 You should start with how to handle JSON data in a POST request. 您应该从如何处理POST请求中的JSON数据开始。 http://edwin.baculsoft.com/2011/12/how-to-handle-json-post-request-using-php/ http://edwin.baculsoft.com/2011/12/how-to-handle-json-post-request-using-php/

That article should help out a bit... 那篇文章应该有所帮助...

Since you don't normally know what that posted data from HubSpot looks like just yet, you can use a service like requestbin to view the data that is being posted.. Note: they might have a cap on the amount of JSON it can handle in the request so you might need to find another service that gives you the complete JSON data or create a script on your server that saves the request to a file. 由于您通常还不知道从HubSpot发布的数据是什么样子,因此可以使用诸如requestbin之类的服务来查看正在发布的数据。在请求中,因此您可能需要找到另一个服务来为您提供完整的JSON数据,或者在服务器上创建一个将请求保存到文件的脚本。 For requestbin, you would create a workflow in hubspot with the action being a webhook and set the type to post and the url to the url that you received when creating a new requestbin. 对于requestbin,您将在hubspot中创建一个工作流,其操作是一个Webhook,并将类型设置为post,并将URL设置为在创建新的requestbin时收到的URL。

Once you know what the JSON data structure is that is coming into your server, you can start to go to work on manipulating that data. 一旦知道了要传入服务器的JSON数据结构,便可以开始处理该数据了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM