I am trying to build it in Php. So far my code based only on what I learn through self-studying.
Please correct me if my code will work and please give me for the code that I am stacked.
Steps:
When someone registers the webhook will trigger:
Inside the webhook, I put Oath code:
//The username and password must match what you enter in your HubSpot workflow webhook
$webhookUsername = “my_username”;
$webhookPassword = “**************”;
$hubspotApiKey = “myhapikey”;
if ($_SERVER[‘PHP_AUTH_USER’] != $webhookUsername || $_SERVER[‘PHP_AUTH_PW’] != $webhookPassword || $_SERVER[‘REQUEST_METHOD’] != ‘POST’){
exit;
}
Getting the details of registered:
$json = $HTTP_RAW_POST_DATA;
$array = json_decode($json, true);
$contactId = $array[‘vid’];
//set the company id if it exists
if($array[‘properties’][‘email’][‘value’] != null){
$emailId = $array[‘properties’][‘email’][‘value’];
}
else{
$emailId = null;
}
Getting the contact email which I will use for update
I’m not proficient in PHP, so I’m not the best resource for troubleshooting your code directly. I’d be happy to help with any HubSpot API issues/questions, but for troubleshooting code you’d be better served elsewhere. I can say that $HTTP_RAW_POST_DATA has been deprecated as of PHP 5.6.0, so you should try php://input instead: http://php.net/manual/en/reserved.variables.httprawpostdata.php
Are you using the hapikey from your Marketing/CRM portal? It sounds like you may have been using the hapikey from your developer portal. Using the correct API key should allow you pull the owners and update contacts successfully.