I’m trying to send select dropdown data to Hubspot via the contact API. For whatever reason, the dropdown select field isn’t being updated.
This is what I’m doing
<?php
function update_member_hubspot( $post_type, $post_id, $old_data, $new_data ) {
$hapikey = "12345";
$arr = array(
'properties' => array(
array(
'property' => 'business_state',
//how to update the select dropdown???
//'options' => array('value' => $new_data["state"]) ????
//'value' => $new_data["state"]) ????
)
)
);
//}
$post_json = json_encode($arr);
//$endpoint = "https://api.hubapi.com/contacts/v1/contact/email/" . $_GET["email"] . "/profile?hapikey=" . $hapikey;
$endpoint = "https://api.hubapi.com/contacts/v1/contact/email/" . $new_data["primary_contact_email"] . "/profile?hapikey=" . $hapikey;
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
@curl_setopt($ch, CURLOPT_URL, $endpoint);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = @curl_exec($ch);
$status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_errors = curl_error($ch);
@curl_close($ch);
$arr = array('curl_errors' => $curl_errors, 'status_code' => $status_code, 'response' => $response);
/*echo "curl Errors: " . $curl_errors;
echo "\nStatus code: " . $status_code;
echo "\nResponse: " . $response;*/
echo json_encode($arr);
}
add_action( 'crm_post_update_hubspot', 'update_member_hubspot', 10, 4 );