Skip to content

Instantly share code, notes, and snippets.

@liorkesos
Created November 23, 2015 07:05
Show Gist options
  • Save liorkesos/d08ae8da7a8561a9c4a9 to your computer and use it in GitHub Desktop.
Save liorkesos/d08ae8da7a8561a9c4a9 to your computer and use it in GitHub Desktop.
<?php
$arr = array(
'properties' => array(
array(
'property' => 'email',
'value' => '[email protected]'
),
array(
'property' => 'firstname',
'value' => 'hubspot'
),
array(
'property' => 'lastname',
'value' => 'user'
),
array(
'property' => 'phone',
'value' => '555-1212'
)
)
);
$post_json = json_encode($arr);
$hapikey = '3733b5b8-5798-4828-9b41-f1e712c2bf83';
$endpoint = 'https://api.hubapi.com/contacts/v1/contact?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);
@curl_close($ch);
echo $response;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment