简体   繁体   中英

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.

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? 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. Here is a post that should get you started: Catching json data from hubspot webhook

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. 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. You should start with how to handle JSON data in a POST request. 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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