hoangweb
12/2/2018 - 9:45 AM

hubspot

<?php
$hubspot = SevenShores\Hubspot\Factory::create('api-key');

// OR instantiate by passing a configuration array.
// The only required value is the 'key'

$hubspot = new SevenShores\Hubspot\Factory([
  'key'      => 'demo',
  'oauth'    => false, // default
  'base_url' => 'https://api.hubapi.com' // default
],null,
[
  'http_errors' => false // pass any Guzzle related option to any request, e.g. throw no exceptions
],
false // return Guzzle Response object for any ->request(*) call);
);

/**
 * contacts
*/
//get single contact
$contact = $hubspot->contacts()->getByEmail("test@hubspot.com");
echo $contact->properties->email->value;

// Get an array of 10 contacts
// getting only the firstname and lastname properties
// and set the offset to 123456
$response = $hubspot->contacts()->all([
    'count'     => 10,
    'property'  => ['firstname', 'lastname'],
    'vidOffset' => 123456,
]);

foreach ($response->contacts as $contact) {
    echo sprintf(
        "Contact name is %s %s." . PHP_EOL,
        $contact->properties->firstname->value,
        $contact->properties->lastname->value
    );
}

// Info for pagination
echo $response->{'has-more'};
echo $response->{'vid-offset'};