Skip to content

Cytracom/package-hubspot-appToken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HubSpot PHP API client

Version Total Downloads License Scrutinizer Code Quality

PHP 5.5+ and Guzzle 6

I've upgraded to Guzzle v6 now.

  • For php 5.3: see the php53 branch. You will need to supply your own HttpClient implementation.
  • For php 5.4: see the php54-guzzle5 branch.

Setup

Composer:

composer require "cytracom/package-hubspot-apptoken": "master"

Or add to your composer.json file

"cytracom/package-hubspot-apptoken": "master"

Quickstart

Instantiate hubspot service

All following examples assume this step.

Note: hubspot api keys are deprecated. You need to pass your private app token.

$hubspot = Fungku\HubSpot\HubSpotService::make('private-app-token');

Get a single contact:

$contact = $hubspot->contacts()->getByEmail("test@hubspot.com");

echo $contact->properties->email->value;

Paginate through all contacts:

// 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,
]);

Working with the data is easy!

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'};

or if you prefer to use array access?

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'];

Now with response methods implementing PSR-7 ResponseInterface

$response->getStatusCode()   // 200;
$response->getReasonPhrase() // 'OK';
// etc...

TLDR

Just drop your app token into the secrets.php and run the example to see data.

php example.php

Status

  • Blog (COS) 🆕
  • Blog Authors (COS) 🆕
  • Blog Posts (COS) 🆕
  • Blog Topics (COS) 🆕
  • Companies 🆕
  • Company Properties 🆕
  • Contacts
  • Contact Lists
  • Contact Properties
  • Deals 🆕
  • Email 🆕
  • Email Events 🆕
  • Events (Enterprise) 🆕
  • Files (COS) 🆕
  • Forms
  • Keywords
  • Page Publishing (COS) 🆕
  • Social Media
  • Templates (COS) 🆕
  • Workflows
  • Tickets

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages