2017 © Pedro Peláez
 

library marketo-php

Marketo PHP REST API client

image

bickart/marketo-php

Marketo PHP REST API client

  • Saturday, November 5, 2016
  • by bickart
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Marketo PHP API client

Version Total Downloads License CodeClimate Test Coverage Build Status, (*1)

Marketo API client. The sequel to my perfectly functional wrapper of HubSpot/haPihP. client. However, this is a complete re-write and includes some of the new COS/v2 endpoints., (*2)

ANNOUNCEMENT!

Setup

Composer:, (*3)

composer require "bickart/marketo-php:1.0.*@dev"

Quickstart

Examples Using Factory

All following examples assume this step., (*4)

$hubspot = Amaiza\Marketo\Factory::create('api-key');

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

$hubspot = new Amaiza\Marketo\Factory([
  'key'      => 'demo',
  'oauth'    => false, // default
  'base_url' => 'https://api.hubapi.com' // default
]);

Note: The Client class checks for a HUBSPOT_SECRET environment variable if you don't include an api key or oauth token during instantiation., (*5)

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!, (*6)

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?, (*7)

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, (*8)

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

Example Without Factory

<?php

require 'vendor/autoload.php';

use Amaiza\Marketo\Http\Client;
use Amaiza\Marketo\Resources\Contacts;

$client = new Client(['key' => 'demo']);

$contacts = new Contacts($client);

$response = $contacts->all();

foreach ($response->contacts as $contact) {
    //
}

Status

If you see something not planned, that you want, make an issue and there's a good chance I will add it., (*9)

  • [ ] Companies :new:
  • [ ] Leads :new:
  • [ ] Opportunities :new:
  • [ ] OpportunityRoles :new:
  • [ ] SalesPersons :new:
  • [x] Stats

The Versions

05/11 2016

dev-dev

dev-dev

Marketo PHP REST API client

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

api marketo

26/09 2016

dev-master

9999999-dev

Marketo PHP REST API client

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

api marketo