2017 © Pedro Peláez
 

library marketo

A PHP client for the Marketo SOAP API.

image

eyefi/marketo

A PHP client for the Marketo SOAP API.

  • Friday, July 1, 2016
  • by kimgust
  • Repository
  • 5 Watchers
  • 0 Stars
  • 2,528 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Marketo

A PHP client for the Marketo SOAP API., (*1)

Installation

Add following line to your composer.json require:, (*2)

``` json "eyefi/marketo": "dev-master", (*3)


And the following to you composer.json repositories: ``` json { "type": "vcs", "url": "https://github.com/eyefi/marketo" }

Usage

Authentication

The first thing you'll want to do is include the marketo class and create a new instance of the client., (*4)

You will need your SOAP user id and SOAP encryption key as well as the hostname for your Marketo API endpoint. These can be found in the Admin -> SOAP section when logged into app.marketo.com., (*5)

If you store configuration in the environment you would create a new instance like:, (*6)

``` php <?php use Marketo\Marketo; $marketo_client = new Marketo($_ENV['MARKETO_USER_ID'], $_ENV['MARKETO_ENCRYPTION_KEY'], $_ENV['MARKETO_SOAP_HOST']);, (*7)


The credentials are passed directly to the class rather than looking for constants or keys stored in superglobals so you can connect to multiple Marketo instances. ### Getting a lead You can get a lead using the `get_lead_by($type, $value)` method. **Arguments** `$type` - The type of ID you would like to look up the lead by. This can be one of the following: - `idnum` - The Marketo lead ID - `cookie` - The entire _mkto_trk cookie - `email` - The email address of the lead - `sdfccontantid` - The Salesforce Contact ID - `sfdcleadid` - The Salesforce Lead ID `$value` - The value for the key. For example if the $type is email the $value should be and email address **Examples** ``` php <?php $marketo_client->get_lead_by('email', 'ben@benubois.com');

This will return an array of lead objects or FALSE if not found. The result will always be an array whether there are one or more leads found., (*8)

Creating or updating a lead

You can create or update a lead using the sync_lead($lead, $lead_key = NULL, $cookie = NULL) method., (*9)

Arguments, (*10)

$lead - Associative array of lead attributes, (*11)

$lead_key - Optional, The key being used to identify the lead, this can be either an email or Marketo ID, (*12)

$cookie - Optional, The entire _mkto_trk cookie the lead will be associated with, (*13)

Examples, (*14)

When no $lead_key or $cookie is given a new lead will be created, (*15)

``` php <?php $marketo_client->sync_lead(array('Email' => 'ben@benubois.com'));, (*16)


When a $lead_key or $cookie is specified, Marketo will attempt to identify the lead and update it. Sending the `_mkto_trk` cookie is important for associating the lead you're syncing with any information Marketo collected when the lead was anonymous. ``` php <?php $marketo_client->sync_lead(array('Unsubscribed' => FALSE), 'ben@benubois.com', $_COOKIE['_mkto_trk']);

This will return the updated or created lead object., (*17)

Adding leads to campaigns

You can add leads to a campaign using the add_to_campaign($campaign_key, $leads) method., (*18)

Arguments, (*19)

$campaign_key - Either the campaign id or the campaign name. You can get these from get_campaigns()., (*20)

$leads - An associative array with a key of lead id type and the corresponding value. This can also be an array of associative arrays. The available id types are:, (*21)

  • idnum - The Marketo lead ID
  • sdfccontantid - The Salesforce Contact ID
  • sfdcleadid - The Salesforce Lead ID

Examples, (*22)

Add one lead to a campaign, (*23)

``` php <?php $client->add_to_campaign(321, array('idnum' => '123456'));, (*24)


Add multiple leads to a campaign with mixed id types ``` php <?php $leads = array( array('idnum' => '123456'), array('sfdcleadid' => '001d000000FXkBt') ); $client->add_to_campaign(321, $leads);

Returns TRUE if successful FALSE if not, (*25)

Getting campaigns

You can get available campaigns using the get_campaigns($campaign = NULL) method., (*26)

Arguments, (*27)

$name - Optional, the exact name of the campaign to get, (*28)

You would usually use this to figure out what campaigns are available when calling add_to_campaign()., (*29)

Returns an object containing all the campaigns that are available to the API. Campaigns are only available to the API if they have a Campaign is Requested trigger where the Source is Web Service API., (*30)

Examples, (*31)

php <?php $marketo_client->get_campaigns();, (*32)

The Versions

01/07 2016

dev-master

9999999-dev

A PHP client for the Marketo SOAP API.

  Sources   Download

MIT

01/07 2016

v1.0.1

1.0.1.0

A PHP client for the Marketo SOAP API.

  Sources   Download

MIT

22/05 2014

v1.0

1.0.0.0

  Sources   Download