PHPackages                             bickart/marketo-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. bickart/marketo-php

ActiveLibrary[API Development](/categories/api)

bickart/marketo-php
===================

Marketo PHP REST API client

017PHP

Since Sep 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/bickart/marketo-php)[ Packagist](https://packagist.org/packages/bickart/marketo-php)[ RSS](/packages/bickart-marketo-php/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Marketo PHP API client
======================

[](#marketo-php-api-client)

[![Version](https://camo.githubusercontent.com/45d93437b40f6d3dc3d5958486d3f0669444d05809862c6ed1c2291ca5564684/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6269636b6172742f6d61726b65746f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bickart/marketo-php)[![Total Downloads](https://camo.githubusercontent.com/fef03189ec1c1caa2f855f24559fa909b1eb5725fc3f1b17002fe9190351b15b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6269636b6172742f6d61726b65746f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bickart/marketo-php)[![License](https://camo.githubusercontent.com/f722a9394584f1524ba69e502de5b143b7cf43a1ba9a553ca9b942b5c0090fc6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6269636b6172742f6d61726b65746f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bickart/marketo-php)[![CodeClimate Test Coverage](https://camo.githubusercontent.com/3aa8a66586aa1814eeeadc55bed70212043630dd732b456701e7bee8ebcc7749/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f6769746875622f6269636b6172742f6d61726b65746f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/bickart/marketo-php/coverage)[![Build Status](https://camo.githubusercontent.com/74055516fb82c05779c35fdac01ab82e4506cf6ee6bb87ce7ea5d384900503b7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6269636b6172742f6d61726b65746f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bickart/marketo-php)

Marketo API client. The sequel to my [perfectly functional wrapper](https://github.com/fungku/hubspot) of HubSpot/haPihP. client. However, this is a complete re-write and includes some of the new COS/v2 endpoints.

ANNOUNCEMENT!
-------------

[](#announcement)

Setup
-----

[](#setup)

**Composer:**

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

Quickstart
----------

[](#quickstart)

### Examples Using Factory

[](#examples-using-factory)

All following examples assume this step.

```
$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.

#### Get a single contact:

[](#get-a-single-contact)

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

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

#### Paginate through all contacts:

[](#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](https://github.com/php-fig/http-message/tree/master/src)

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

### Example Without Factory

[](#example-without-factory)

```
