Download the PHP package bbathel12/marketing-cloud-php-sdk without Composer

On this page you can find all versions of the php package bbathel12/marketing-cloud-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package 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

PHP version 5.6.x, 7.x

Extensions:

DataProBoston SDK uses Guzzle as HTTP client, its' requirements can be found on http://docs.guzzlephp.org/en/latest/overview.html#requirements

Installation

composer require dataproboston/marketing-cloud-php-sdk

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(['[email protected]'], $listId);

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

$senderProfileId = $driver->createSenderProfile('Test sender profile', 'Sender name', '[email protected]');

// 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

AuthClient

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

Constructor parameters:

SoapClient

Constructor parameters:

Create method

Method arguments:
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.

Method arguments:
Return value:

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

Method arguments:
Return value:

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

Method arguments:
Return value:

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:
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

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:
Return value:

Same as in Retrieve method.

Usage:
// 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 thrown by DataProBoston SDK are instances of DataProBoston\MarketingCloud\Exception\ClientException interface.

List of available exceptions:

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:

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

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

Utility methods

Running tests

Copy phpunit.xml.dist to phpunit.xml and provide your settings (clientId, clientSecret, etc.) in \ section.

Issues and support

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

Copyright and license

(c) 2017 Yaroslav Honcharuk [email protected]

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


All versions of marketing-cloud-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
ext-soap Version *
paragonie/random_compat Version >=2.0.4
guzzlehttp/guzzle Version ^6.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bbathel12/marketing-cloud-php-sdk contains the following files

Loading the files please wait ....