Updating Email Contact Properties for HubSpot in PHP

Marketing Strategy

Here we will see how we can update the HubSpot contact by using PHP code, if we know only the contact's email.

So let's suppose we have a contact [email protected] and we have properties such as phone no, premium, amount and we want to update it from our PHP script.


<?php
$email = "[email protected]";
define("HUBSPOT_API_URL","https://api.hubapi.com");
define("HUBSPOT_API_KEY","TESTAPIKEY");
$url = HUBSPOT_API_URL . "/contacts/v1/contact/email/" . $email . "/profile?hapikey=" . HUBSPOT_API_KEY;
$phoneno = 9999112233;
$premium = "YES";
$amount = 5000;
$properties = array();
$properties['properties'][] = array('property' => 'phoneno', 'value' => $phonene);
$properties['properties'][] = array('property' => 'premium', 'value' => $premium);
$properties['properties'][] = array('property' => 'amount', 'value' => $amount);
?>

The $url contains the URL to send the request and $properties contain the structured way of the request body which HubSpot accepts.

Now we can request this data using any platform, curl, drupal_http_request or simple HTTP REST.