Example of how to get Hubspot ID or Email from Recents
Within the contact response, I am looking to return the email address of each user.
$response = $hubspot->contacts()->recent([
'count' => 20,
'property' => ['firstname', 'lastname'],
]);
foreach ($response->contacts as $contact) {
echo sprintf(
"Contact name is %s %s." . PHP_EOL,
$contact->properties->firstname->value,
$contact->properties->lastname->value
);
}
The email appears to be an array nested object and I am having difficulties finding an example of how this has been done anywhere in the repo.
as a simple example, you can use: 'property' => ['firstname', 'lastname','email'],
but then for printing, you should use: foreach ($response->contacts as $contact) { echo sprintf( "Contact name is %s %s, email %s." . PHP_EOL, $contact->properties->firstname->value, $contact->properties->lastname->value, @$contact->properties->email->value ); }
HubSpot for email, same as phone, does not create field once the user is created
Thanks @tmikeska but how to get the 'vid'? The HubspotID. I tried:
'property' => ['firstname', 'lastname','vid'],
foreach ($response->contacts as $contact) { echo sprintf( "Contact name is %s %s, email %s." . PHP_EOL, $contact->properties->firstname->value, $contact->properties->lastname->value, @$contact->properties->vid->value ); }
But that didn't work out.
vid is not a part of contact properties. Try $contact->vid
Thanks a lot! Got it. Can you pls suggest also how to get photo? Tried $contact->photo and $contact->properties->photo->value and also $contact->propertie->photo but no results. Where do you check if value belongs under properties or not?
@e-stonia https://developers.hubspot.com/docs/methods/contacts/get_contact
$contact->profile_url ?
$contact->profile_url returns nothing. Tried also $contact->profile-url and that one returns value 0. But then I tried just directly via URL https://api.hubapi.com/contacts/v1/lists/all/contacts/recent?hapikey=[[[my_hapi]]]&property=profile_url and that returned me this URL: https://app.hubspot.com/contacts/5049387/lists/public/contact/_AO_T-mMM8phpwNi-jjYzzN9-XQuXJSCKu4ovbmSCKJFRQhoqVD81k3f-H0T-pjJS8b2RepD515t1brePbfD7QtiyhbbB4tRgFvNKVXmQPGDJgEk6357dbd5Xr9HVU47mC_wuv8m8Im0b/ Although this contact has profile image as you can see in this profile URL you can't see the image. Otherwise could just write dirty hack and get the image from URL.
OK, got answer to my question - it doesn't exist in API: https://integrate.hubspot.com/t/how-do-i-get-the-avatar-logo-of-a-contact-company/729
Or is there an option to send avatar photo to HubSpot? My issue is that I need data in 2-3 places and don't need to be able to upload/update avatar in all places. So it could be an option to only upload avatar outside HubSpot and then it gets uploaded via API to HubSpot.
Hi @e-stonia You can upload an photo using Files API then create a custom property and put link to the photo there