PHPackages                             bbathel12/marketing-cloud-php-sdk - 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. bbathel12/marketing-cloud-php-sdk

ActiveLibrary[API Development](/categories/api)

bbathel12/marketing-cloud-php-sdk
=================================

fork of DataProBoston Salesforce Marketing Cloud (formerly ExactTarget) PHP SDK

v0.1.0(9y ago)04MITPHPPHP &gt;=5.6.0

Since Mar 1Pushed 4y agoCompare

[ Source](https://github.com/bbathel12/marketing-cloud-php-sdk)[ Packagist](https://packagist.org/packages/bbathel12/marketing-cloud-php-sdk)[ RSS](/packages/bbathel12-marketing-cloud-php-sdk/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (3)Used By (0)

Salesforce Marketing Cloud PHP SDK
==================================

[](#salesforce-marketing-cloud-php-sdk)

DataProBoston Salesforce Marketing Cloud (formerly ExactTarget) PHP SDK.

\##Overview ## DataProBoston SDK provides clean and easy way to interact with Salesforce Marketing Cloud API's. Currently only SOAP API is supported, REST API support will be added in future releases.

Requirements
------------

[](#requirements)

PHP version 5.6.x, 7.x

Extensions:

- soap
- curl \[recommended\]

DataProBoston SDK uses Guzzle as HTTP client, its' requirements can be found on

Installation
------------

[](#installation)

composer require dataproboston/marketing-cloud-php-sdk

Basic usage
-----------

[](#basic-usage)

```
use DataProBoston\MarketingCloud\AuthClient;
use DataProBoston\MarketingCloud\SoapClient;

$authClient = new AuthClient([
    'clientId' => CLIENT_ID,
    'clientSecret' => CLIENT_SECRET,
]);

$client = new SoapClient(null, [], $authClient);

// Create object
$listId = $client->create('List', [
    'ListName' => 'test',
]);

// Create mulpiple objects in one call - $listsIds is an array of objects' identifiers.
$listsIds = $client->create('List', [
    [
        'ListName' => 'test5',
    ],
    [
        'ListName' => 'test6',
    ],
]);

// Array of properties to retrieve.
$properties = ['ListName'];

$filter = ['ID', '=', $listId];

// Retrieve one object - $list is an object of \stdClass
$list = $client->retrieveOne('List', $properties, $filter);

// Retrieve collection of objects - $lists is an array of objects of \stdClass
$lists = $client->retrieve('List', $properties);

$client->update('List', [
    'ID' => $listId,
    'ListName' => 'test2',
]);

$client->delete('List', [
    'ID' => $listId,
]);

// Delete mulpiple objects in one call
$client->delete('List', [
    [
        'ID' => $listsIds[0],
    ],
    [
        'ID' => $listsIds[1],
    ],
]);

```

In addition to low-level SoapClient and RestClient, DataProBoston SDK provides high-level Driver abstraction, that provides useful high-level methods.
Driver also can be used as a source for examples.

Example workflow to send email campaign using Driver:

```
use DataProBoston\MarketingCloud\Driver;

$driver = new Driver($soapClient);

$listId = $driver->createList('Test campaign');

$driver->createSubscribers(['youremail@gmail.com'], $listId);

$emailId = $driver->createEmail('Test campaign', 'Test campaign subject', 'Test campaign body');

$senderProfileId = $driver->createSenderProfile('Test sender profile', 'Sender name', 'senderemail@gmail.com');

// Assumed that API account has DeliveryProfile with CustomerKey value 'Default'.
$sendClassificationId = $driver->createSendClassification('Test send classification', $senderProfileId, 'Default');

$emailSendDefinitionId = $driver->createEmailSendDefinition($listId, $emailId, $sendClassificationId);

$sendId = $driver->sendEmailSendDefinition($emailSendDefinitionId);

```

Documentation
-------------

[](#documentation)

### AuthClient

[](#authclient)

AuthClient is extracted in a separate class to be shared between SoapClient and RestClient (will be available in future releases).

#### Constructor parameters:

[](#constructor-parameters)

- options (array). Available options:
    - clientId (string). Required.
    - clientSecret (string). Required.
    - authTokenMinExpirationTime (int). Min time in seconds remaining to token expiration that will cause token refresh. Default value - 30.
    - timeout (float). Request timeout in seconds. Default value - 10.
    - sslVerifyPeer (bool|string). Enables / disables SSL certificate verification. See . Default value - false.

### SoapClient

[](#soapclient)

#### Constructor parameters:

[](#constructor-parameters-1)

- wsdl (string). Absolute path to WSDL file. If null, the bundled one (depending on wsdlInstance option) will be used.
- options (array). Available options:
    - wsdlInstance (string). Instance of bundled WSDL to use. Available instances: 'main', 's4', 's6', 's7', 'test'. Default value - 'main'.
    - timeout (float). Request timeout in seconds. Default value - 60.
    - sslVerifyPeer (bool|string). Enables / disables SSL certificate verification. See . Default value - false.
- authClient (AuthClient).

#### Create method

[](#create-method)

##### Method arguments:

[](#method-arguments)

- objectType (string).
- object (array). Object argument can be:

    - associative array with object's properties (one object mode).
    - numeric array of associative arrays with objects' properties (multiple objects mode).
- upsert (bool). Only some objects support upsert.

##### Return value:

[](#return-value)

Object identifier or array of objects identifiers depending on $object argument. In case of multiple objects mode, indexes in returned array will correspond to indexes in $object argument.

On error, method will throw an instance of DataProBoston\\MarketingCloud\\Exception\\ClientException interface.

See "Exceptions handling" for more information.

> Note: Marketing Cloud API uses two types of object's identifiers:
>
> - Legacy identifier (ID, int).
> - Actual identifier (ObjectID, string).
>
> Official documentation doesn't provides information about the identifier type that is used for each object.
>
> Create method automatically returns correct identifier.
>
> To update / delete / filter by an identifier, one should correctly specify it's property name ('ID' or 'ObjectID'). Currently, property name can be simply determined by create method return value - if it's an integer - than property name is 'ID', if string - 'ObjectID'.
>
> Auto selecting correct identifier property is planned for future releases.

> Note: Marketing Cloud API uses special Configure method to create / update / delete PropertyDefinition and Role objects. To standardize usage, DataProBoston SDK provides support of this operations via general Create / Update / Delete methods, and internally calls Configure method.

#### Update and Delete methods.

[](#update-and-delete-methods)

##### Method arguments:

[](#method-arguments-1)

- objectType (string).
- object (array). Same format as in create method.
    For update method object identifier property should be specified alongside with object's properties to update.
    For delete method object identifier property only is enough.
    Usage of other objects' properties instead of identifiers to select objects for update/delete is currently undetermined.

##### Return value:

[](#return-value-1)

No value is returned.

On error, method will throw an instance of DataProBoston\\MarketingCloud\\Exception\\ClientException interface.

See "Exceptions handling" for more information.

#### Perform method

[](#perform-method)

##### Method arguments:

[](#method-arguments-2)

- objectType (string).
- object (array). Same format as in create method.
- action (string). String 'start' is used in most cases, see

##### Return value:

[](#return-value-2)

Task identifier or array of tasks identifiers depending on $object argument. In case of multiple objects mode, indexes in returned array will correspond to indexes in $object argument.

On error, create method will throw an instance of DataProBoston\\MarketingCloud\\Exception\\ClientException interface.

See "Exceptions handling" for more information.

#### Retrieve and RetrieveOne methods

[](#retrieve-and-retrieveone-methods)

##### Method arguments:

[](#method-arguments-3)

- objectType (string).
- properties (array). Properties of object(s) to retrieve.
- filters (array). 3-element numeric array, in 2 possible forms:
    - Simple condition: \[$property, $operator, $value\]
    - Logical condition: \[$leftCondition, $operator, $rightCondition\].
        Applied if operator is 'and' or 'or'.
        $leftCondition / $rightCondition itself could be simple conditions or nested logical conditions.
        Dates in filter values should be represented by \\DateTime objects.
- sinceLastBatch (bool). Only for Retrieve method.
    Retrieve only objects added/modified since last retrieve call with the same properties and filters.

##### Return value:

[](#return-value-3)

Array of \\stdClass objects for Retrieve method, and object of \\stdClass for RetrieveOne method. In case of no results, RetrieveOne method will return null. In case of more than 1 result, RetrieveOne method will throw ResponseException exception.

##### Available filter operators:

[](#available-filter-operators)

- =
- !=
- &gt;
- &lt;
- &gt;=
- &lt;=
- isNull
- !isNull
- between
- in
- like
- and
- or

##### Usage:

[](#usage)

```
$sendId = 11111;
$startDate = new \DateTime();
$finishDate = new \DateTime();
$startDate->modify('-1 day');

$properties = ['SubscriberKey', 'EventDate'];

$filter = [
    ['SendID', '=', $sendId],
    'and',
    ['EventDate', 'between', [$startDate, $finishDate]]
];

$sentEvents = $client->retrieve('SentEvent', $properties, $filter);

```

#### RetrieveMore method

[](#retrievemore-method)

Retrieve method returns max. 2500 objects at one call. To retrieve all objects, one should check if there are more results using hasMoreResults() method and call retrieveMore(), if any.

##### Method arguments:

[](#method-arguments-4)

- requestId (string|null). If not specified, the one from getLastRequestId() will be used. In this case it's not possible to call other methods while iterating through results. To be able to call other methods, one should obtain requestId using getLastRequestId() and pass it to retrieveMore().

##### Return value:

[](#return-value-4)

Same as in Retrieve method.

##### Usage:

[](#usage-1)

```
// without any other method calls
$subscribers = $client->retrieve('Subscriber', ['ID']);
while ($client->hasMoreResults()) {
    $subscribers = $client->retrieveMore();
}

// with other method calls
$subscribers = $client->retrieve('Subscriber', ['ID']);
$requestId = $client->getLastRequestId();
while ($client->hasMoreResults()) {
    $subscribers = $client->retrieveMore($requestId);
}

```

#### Exceptions handling

[](#exceptions-handling)

Exceptions thrown by DataProBoston SDK are instances of DataProBoston\\MarketingCloud\\Exception\\ClientException interface.

List of available exceptions:

- RequestException. Thrown if an error occurred before request to API.
- ResponseException. Thrown if an error occurred after request to API.
    - MultipleModeResponseException. Thrown if an error occurred after request to API, in Create / Update / Delete / Perform methods in multiple objects mode.

In multiple objects mode some objects can be processed successfully, some have errors. If at least one error present, DataProBoston SDK will throw MultipleModeResponseException exception. This exception has 2 useful methods:

- getErrors(). Returns an array of errors, where each error is 2-element array of message (string) and code (int). Indexes correspond to indexes in $object argument of SoapClient method call.
- getCreatedObjectsIdentifiers(). Returns an array of identifiers identically to return value of Create / Perform methods. Indexes correspond to indexes in $object argument of SoapClient method call.

##### Usage:

[](#usage-2)

```
try {
    $client->create('List', [
        [
            'ListName' => 'test1',
        ],
        [
            'ListName' => 'test2',
        ],
    ]);
} catch (MultipleModeResponseException $e) {
    // errors
    $errors = $e->getErrors();

    // successfully created objects identifiers
    $identifiers = $e->getCreatedObjectsIdentifiers();
}

```

#### Utility methods

[](#utility-methods)

- describe(objectType). Returns array of all objectType properties (\\stdClass objects).
- describeSubscriberAttributes(). Returns array of all Subscriber object attributes ("extended properties") (\\stdClass objects).
- systemStatus(). Returns system status string: 'OK'|'InMaintenance'|'UnplannedOutage'.
- versionInfo(includeVersionHistory). Returns API version info (\\stdClass object).
- requestEndpoint(). Returns API endpoint URL (string).
- getFilterOperators(). Returns array of available filter operators.
- getLastRequestId(). Returns last request id (string).
- hasMoreResults(). Indicates if retrieve request has more results (bool).
- execute. Usable only for retrieving user token:

    ```
      $requests = [
          'Name' => 'GetUserToken',
      ];

      $response = $client->execute($requests);

    ```

Running tests
-------------

[](#running-tests)

Copy phpunit.xml.dist to phpunit.xml and provide your settings (clientId, clientSecret, etc.) in &lt;php&gt; section.

Issues and support
------------------

[](#issues-and-support)

Feel free to contact us on Github with any issues / questions / suggestions.

Copyright and license
---------------------

[](#copyright-and-license)

(c) 2017 Yaroslav Honcharuk

Licensed under the MIT License. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3359d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/14ae89c70b41c71bf396211708f09135c6ed9083c6004c869a2a493967bd034b?d=identicon)[bbathel12](/maintainers/bbathel12)

---

Top Contributors

[![bbathel12](https://avatars.githubusercontent.com/u/13651403?v=4)](https://github.com/bbathel12 "bbathel12 (6 commits)")[![yarhon](https://avatars.githubusercontent.com/u/15655604?v=4)](https://github.com/yarhon "yarhon (3 commits)")

### Embed Badge

![Health badge](/badges/bbathel12-marketing-cloud-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/bbathel12-marketing-cloud-php-sdk/health.svg)](https://phpackages.com/packages/bbathel12-marketing-cloud-php-sdk)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
