1. Go to this page and download the library: Download fotografde/hubspot-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fotografde / hubspot-php example snippets
$hubspot = SevenShores\Hubspot\Factory::create('api-key');
// OR instantiate by passing a configuration array.
// The only tps://api.hubapi.com' // default
]);
$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
);
// 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'};
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'];