Real-Time Personalization (+RTP) API Guide

Integration

Sequencing.com has already everything to simplify integration of AppChains API into your PHP based project.

In order to integrate it, get code from our GitHub repository and paste it into your project. Code is PHP5 compatible and is OO based.

 

PHP module API

Method Purpose Arguments Description
public function __construct($token = null, $chainsHostname = null) Constructor Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required
public function getReport($remoteMethodName, $applicationMethodName, $datasourceId) Reporting API
  • remoteMethodName - REST endpoint name, use "StartApp" 
  • applicationMethodName - name of data processing routine 
  • datasourceId - input data identifier 
 
public function getBatchReport($remoteMethodName, $appChainParam) Batch reporting API
  • remoteMethodName - REST endpoint name, use "StartAppBatch" 
  • appChainParam - associative array where keys are chain identifiers and values are file identifiers  
 

 

Code snippet

Adding code to the project:

  • Add AppChains.php into your source folder and import (require_once("AppChains.php");) it in your PHP file.

For complete usage example, refer to our code in GitHub repository.

Single App Chain retrieval example

$chains = new AppChains("<your token goes here>", "api.sequencing.com");
$chainsResult = $chains->getReport("StartApp", "Chain88", "227680");
 
if ($chainsResult->isSucceeded())
    echo "Request has succeeded\n";
else
    echo "Request has failed\n";
 
foreach ($chainsResult->getResults() as $r)
{
    $type = $r->getValue()->getType();
 
    switch ($type)
    {
        case ResultType::TEXT:
            $v = $r->getValue();
            echo sprintf("-> text result type %s = %s\n", $r->getName(), $v->getData());
        break;
        case ResultType::FILE:
            $v = $r->getValue();
            echo sprintf(" -> file result type %s = %s\n", $r->getName(), $v->getUrl());
            $v->saveTo("d:\data");
        break;
    }
}

Batch App Chain retrieval example

$chains = new AppChains("<your token goes here>", "api.sequencing.com");
 
$chainsBatchResult = $chains->getBatchReport("StartAppBatch", array("Chain91" => "227680", "Chain88" => "227680"));
foreach ($chainsBatchResult as $key => $value){
   echo "-> Chain ID:";
   echo $key;
   echo "\n";
   printReport($value);
}