joesexton00/exacttarget

ExactTarget API 组件库

1.1.0 2013-12-30 14:56 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:12:30 UTC


README

包: joesexton00\exactTarget
使用: EtBaseClass.php
版本 1.1

这是Micah Breedlove的Exact Target包的一个分支,在此基础上增加了数据扩展功能和一些其他功能。对这个包的贡献应归功于他!

通用

ExactTarget组件是基于ExactTarget PHP启动套件的类集合。该库的目的是减少编写Exact Target代码的时间,更多地与您的应用程序工作。EtClient处理所有SOAP通信。此类包含多个函数(如下定义),使得EtClient在基本级别上可以自给自足。ExactTarget API PHP启动套件(可用:http://docs.code.exacttarget.com/@api/deki/files/199/=PHP_APIstarterKit-V1.zip 源:http://docs.code.exacttarget.com/020_Web_Service_Guide/API_Starter_Kits

用法

EtClient是访问ExactTarget API的主要途径。所有交互都应该通过它进行。可以在EtClient文件之外使用其他类。

每个魔法函数都像Symfony-like 魔法获取器和设置器一样工作。创建、调用、更新和捆绑每个都执行SOAP调用以执行其预期操作。

示例(订阅者):

// instantiates the Client for SOAP Communications
$client = new EtClient($userName,$password);

// Subscriber object is passed the client
$subscriber = new EtSubscriber($client);

$subscriberKey = $emailAddress = "user@domain.com";
// Find a subscriber from ExactTarget by subscriber key (email address is
// optional)
$subscriber->find($subscriberKey, $emailAddress);

// Add Subscriber to a specific list (by list id)
$subscriber->addToList("24601");

// Build a new Attribute
$newAttrib = new EtAttribute();
$newAttrib->setName('Metroid Save Code'); // Attribute Name
$newAttrib->setValue("------ ---mE3 l-y000 00y00j"); // Attribute Value

// setAttributes is be used for initially setting attributes on subscriber
$subscriber->setAttributes(array($newAttrib));
// updateAttribute is used for objects which already have attributes
// $subscriber->updateAttribute($newAttrib);

// Update Subscriber record
$subscriber->save();
/* either by the save method on EtSubscriber or
 * via the EtClient
 * $client->updateSubscriber($subscriber, 'updateOnly');
 */

示例(触发性发送):

// Initialize EtClient
$client = new EtClient($userName,$password);

// create Triggered Send object giving it access to the EtClient object
$ts = new EtTriggeredSend($client);

// Define which triggered send to use
$ts->useKey("defeatedMotherBrain");

// create Subscriber object giving it access to the EtClient object
$sub = new EtSubscriber($client);

// search for a user by subscriber key [required] and
// email address [optional]
$sub->find("user@domain.com","user@domain.com");

// define the subscribers the Triggered Send is bound for
$ts->setSubscribers(array($sub));

// execute send
$ts->send();

示例(数据扩展):

// initialize
$this->dataExtension->init();

// retrieve the DE, specify which fields to get
$this->dataExtension->find( array( 'field1', 'field2', 'field3' ) );

// update a DE property using key/value pair
$this->dataExtension->updateProperty( 'key', 'value' );

// persist
$this->dataExtension->save();

EtClient

这是库的核心。ExactTarget启动套件提供了一系列示例,这些示例以非常散乱的方法使用SOAP调用。这把所有与SOAP调用的交互放在了一个地方。

####函数

该客户端内置了三个(3)函数调用

  • buildTriggeredSend
  • sendEmail
  • getDefinitionOfObject

buildTriggeredSend函数接受两个(2)参数,第一个是必需的,是triggeredSendKey,它是特定触发电子邮件的“外部键”,可以在Web UI的“交互”>“消息”>“触发发送”下找到。

第二个是可选的,是一个作为键值对构建的数组,应与EtTriggeredSendDefinition类上可用的变量对应。

$EtClient->buildTriggeredSend($triggeredSendKey, [$optionalAttributesArray]);

sendEmail函数接受两个(2)必需变量,第一个是有效的Et对象,可以用于发送(例如,EtTriggeredSend,EtEmail等),第二个是SendType,它是用于SOAP通信的对象类型。

$EtClient->sendEmail($EmailableClass, $EmailableClassType);

getDefinitionOfObject函数是由Exact Target PHP启动套件提供的函数,用于获取Exact Target记录的属性(可以想象mysql> DESC

;)并返回“可检索”的属性。

$EtClient->getDefinitionOfObject($EtClass);

  • 魔法

该客户端内置了四个(4)魔法函数调用(有关其使用示例,请参阅下面的“用法”部分)。

  • create - 创建并返回指定的Et对象
  • recall - 根据提供的筛选参数检索现有Exact Target记录的Et类(如果不存在则返回false)
  • update - 根据给定的Et对象更新现有Exact Target记录
  • bundle - 批量更新方法,将调用用于添加许多订阅者等的更新请求。

变更日志

###1.0 ####客户端访问EtEmail、EtList、EtSubscriber和EtTriggeredSend现在可以通过EtClient传递,以便进行保存和发送功能(见下文)。 ####保存方法EtEmail、EtList和EtSubscriber对象现在具有save()方法,无需手动调用客户端更新。 ####发送方法EtEmail和EtTriggeredSend对象现在具有send()方法,无需手动调用客户端发送电子邮件。 ###1.0.2 ####composer.json文件添加了lib-openssl和ext-mcrypt。 ###1.1.0 #####新功能添加了数据扩展包装和一些其他功能。

贡献者