Skip to content

hglattergotz/ExactTarget-PHP-SOAP-API

Repository files navigation

ExactTarget

PHP wrapper for ExactTarget SOAP API

This is a php library for accessing a subset of ExactTarget's SOAP API. It provides synchronous CRUD operations on Data Extensions and Subscriber Lists by exposing a Doctrine-like API (Record, Table, Collection). The ExactTarget API documentation can be found here.




To interact with the Soap API the library provides the basic classes that represent a Record, Table and Collection.

The names are pretty self explanatory and if you are familiar with Doctrine this will be very familiar.

  • The record class allows for manipulation of a single record (CRUD).
  • The table class exposes queries on the entire table and returns one or more records in form of a collection.
  • A collection is a container class that holds a variable number of record objects and provides various methods to iterate over them or to create, update or delete them with a single operation.

To interact with a Data Extension with the following schema you simply extend the AbstractETDataExtensionObject and AbstractETDataExtension classes.

Schema

<?php
id (primary key)
firstname
lastname
email

Record

<?php
class PersonDataExtensionObject extends AbstractETDataExtensionObject
{
    protected function configure()
    {
        $this->customerKey = 'my customer key for this DE';
        $this->schema = array(
            'id' => array(
                'is_primary'  => true,
                'is_required' => true,
                'type'        => self::TYPE_NUMBER),
            'firstname' => array(
                'is_primary'  => false,
                'is_required' => false,
                'type'        => self::TYPE_TEXT),
            'lastname' => array(
                'is_primary'  => false,
                'is_required' => false,
                'type'        => self::TYPE_NUMBER),
            'email' => array(
                'is_primary'  => false,
                'is_required' => true,
                'type'        => self::TYPE_NUMBER)
        );
    }
}

Table (Data Extension)

<?php
class PersonDataExtension extends AbstractETDataExtension
{}

Important: The two related classes must have the same name, but the Record class has Object appended to it.

Fetch a record from the data extension and modify it.
<?php
ETCore::initialize('myusername', 'mypassword');

$personDE = new PersonDataExtension();
$allPeople = $personDE->findAll(ETCore::HYDRATE_RECORD);
$person = $allPeople->getFirst();
$person->setfirstname('Joe');
$person->save();
Create a new record
<?php
ETCore::initialize('myusername', 'mypassword');

$personData = array(
    'id' => 123,
    'firstname' => 'Joe',
    'lastname' => 'Smith',
    'email' => 'joe@smith.com'
);
$person = new PersonDataExtensionObject();
$person->fromArray($personData);
$person->save();

Please refer to the LICENSE file in this repository.


ExactTarget is a registered trademark of ExactTarget, Inc.

About

A php library for accessing the ExactTarget SOAP API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages