PHP code example of ariad / exacttarget-laravel

1. Go to this page and download the library: Download ariad/exacttarget-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ariad / exacttarget-laravel example snippets



	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)

}



	/* asynchronously upsert a batch of Rows to a DE*/
	return $this->etConnect()->asyncUpsertRowset(["primaryKey" => 1], ["emailAddress" => "[email protected]"], 'TestingRest  ');

	/* upsert a single row to a DE */
	return $this->etConnect()->upsertRow('primaryKey', 1, ['emailAddress' => '[email protected]'], 'TestingRest');

	/* Validate an Email address */
	return $this->etConnect()->validateEmail('[email protected]');

	/* Delete a Row from a DE */
	return $this->etConnect()->deleteRow('TestingRest', ['primaryKey' => 1]);