Hello everyone. I’m having an issue with creating contacts with the PHP basic API call:
<?php
use HubSpot\Factory;
use HubSpot\Client\Crm\Contacts\ApiException;
$client = Factory::createWithAccessToken('YOUR_ACCESS_TOKEN');
try {
$apiResponse = $client->crm()->contacts()->basicApi()->getPage(10, false);
var_dump($apiResponse);
} catch (ApiException $e) {
echo "Exception when calling basic_api->get_page: ", $e->getMessage();
}
The issue is that documentation doesn’t specify how to pass Hubspot’s cookie ID, form ID, url and page name when the contact is created. I tried passing the $context as an additional option but I understood that it won’t be processed by the PHP class, so I’m stuck at this point:
$context = [
'formId' => $request->context['formId'],
'hutk' => $request->context['hutk'],
'pageUri' => $request->context['pageUri'],
'pageName' => $request->context['pageName']
];
$createContact = new SimplePublicObjectInputForCreate([
'associations' => null,
'properties' => $properties,
'context' => $context,
]);
Can I do it with the Hubspot PHP code or is it better to use the legacy API? Thanks in advance.