ariad / exacttarget-laravel
Ariad 对 Hypertext PreProcessor 与 Exact Target 交互的最佳实践的定制
2.9
2017-07-10 14:51 UTC
Requires
- php: ~5.5|~7.0
- illuminate/support: ~5.0
Requires (Dev)
- guzzlehttp/guzzle: ~6.0
- guzzlehttp/psr7: 1.0.0
- laravel/homestead: ^3.0
- phpunit/phpunit: 5.0.*
- psr/http-message: 1.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
README
该 Laravel 包提供了一套用于与全新的 Exact Target REST API 清晰、便捷交互的方法,以及用于 Fuel SDK 的方法。
它实现了以下协议,说明了目前在您的控制器或模型中可用的内容。您可以从注释中了解每个方法将做什么。这是一个正在进行中的工作,还有很多更多端点需要创建方法。
此构建包含一个 Laravel 的实现。
<?php interface EtInterface { /** * reaches out to Exact Target Rest API with client secret and Id * returns the auth token * * Client is the guzzle object and all the methods you need * * @param $clientId * @param $clientSecret * @param $getTokenUri * @param Client $client * @return array */ public function getToken($clientId, $clientSecret, $getTokenUri); /** * POST * * /dataevents/key:{key}/rowset * * Upserts a batch of data extensions rows by key. * * @param $keys * @param $values * @param Client $client * @return array */ public function upsertRowset($values, $deKey); /** * SOAP WDSL * * uses the Fuel SDK to delete a row by Primary Key * currently the v1 of the REST api does not support retrieval of data. * Hopefully this will change in the near future * * @param $deName * @param $props * @return array -- the response from Exact Target */ public function deleteRow($deName, $props); /** * @param $deName * Required -- Name of the Data Extension to query * * @return array */ public function getDeColumns($deName); /** * SOAP WDSL * * uses the Fuel SDK to grab all the rows of a given Data Extension * currently the v1 of the REST api does not support retrieval of data. * Hopefully this will change in the near future * * * @param $keyName * This is an optional param if set along with primaryKey the result will be filtered to a single row by PrimaryKey * @param $primaryKey * This is an optional param if set along with keyName the result will be filtered to a single row by PrimaryKey * @param $deName * Required -- Name of the Data Extension to query * @return array * Response from ET */ public function getRows($deName, $keyName='', $primaryKey=''); /** * POST * * Asynchronously upserts a batch of data extensions rows by key. * * these async methods need testing when / if we have a need for async requests (which we will) * * /dataeventsasync/key:{key}/rowset * */ public function asyncUpsertRowset($keys, $values, $deKey); /** * PUT * * Upserts a data extension row by key. * * /dataevents/key:{key}/rows/{primaryKeys} */ public function upsertRow($pKey, $pVal, $values, $deKey); /** * PUT * * Asynchronously upserts a data extension row by key. * * these async methods need testing when / if we have a need for async requests (which we will) * * /dataeventsasync/key:{key}/rows/{primaryKeys} */ public function asyncUpsertRow($pKey, $pVal, $values, $deKey); /** * Create a Data extension by passing an array of DE Name keys => Column props values. * * @param $deStructures * @return array (response) */ public function createRow($deName, $props); /** * POST * * To validate an email address, perform an HTTP POST specifying the email address and validators * to be used in the payload of the HTTP POST. You can use more than one validator in the same call. * * /validateEmail * */ public function validateEmail($email); /** * Create a Data extension by passing an array of DE Name keys => Column props values. * * @param $deStructures * @return array (response) */ public function createDe($deStructures) }
安装
首先,通过 Composer 安装此包。编辑您项目中的 composer.json
文件,以添加 digitaladditive/exacttargetlaravel
依赖。或者,只需运行 composer require digitaladditive/exacttargetlaravel
"require-dev": {
"digitaladditive/ExactTargetLaravel": "~1.1"
}
接下来,在终端中更新 Composer
composer update --dev
接下来,您需要在包根目录下的 ExactTargetLaravelConfig.php
文件中填写您的 Exact Target API 凭据(CLIENT_ID 和 CLIENT_SECRET)。
请确保您已安装并启用了 'mcrypt' 在您的 Web 服务器上,否则 Fuel SDK 调用将失败
现在只需在 Laravel 应用文件顶部添加一个使用声明,如下所示
use digitaladditive/ExactTargetLaravel/LaravelEtApi;
用法
一些用法示例
<?php /* asynchronously upsert a batch of Rows to a DE*/ return $this->etConnect()->asyncUpsertRowset(["primaryKey" => 1], ["emailAddress" => "newemail@newemail.com"], 'TestingRest '); /* upsert a single row to a DE */ return $this->etConnect()->upsertRow('primaryKey', 1, ['emailAddress' => 'oncemore@oncemore.com'], 'TestingRest'); /* Validate an Email address */ return $this->etConnect()->validateEmail('patrickisgreat@gmail.com'); /* Delete a Row from a DE */ return $this->etConnect()->deleteRow('TestingRest', ['primaryKey' => 1]);