Expand my Community achievements bar.

SOLVED

PHP and Adobe Target Delivery API

Avatar

Level 3

Hello!

I am trying to implement the Adobe Target Delivery API using PHP code in order to get data about our current AB test experiences. This is what my request looks like:

 

$client = new Client();

$url = self::ADOBE_API_URL . '?client=' . self::ADOBE_CLIENT_ID . '&sessionId=' . self::ADOBE_SESSION_ID;

$headers = array();
$data = array();
$mboxes = array();
$request_data = array();

$mboxes[0]['name'] = self::ADOBE_TARGET_MBOX_SCOPE1;
$mboxes[0]['index'] = 1;
$mboxes[1]['name'] = self::ADOBE_TARGET_MBOX_SCOPE2;
$mboxes[1]['index'] = 2;
      
$headers['Content-Type'] = 'application/json';
$headers['cache-control'] = 'no-cache';

$data['context']['channel'] = self::ADOBE_CONTEXT_CHANNEL;
$data['property']['token'] = self::ADOBE_PROPERTY_TOKEN;
$data['prefetch']['mboxes'] = $mboxes;
$data['execute']['mboxes'] = $mboxes;

$request_data['headers'] = $headers;
$request_data['json'] = $data;

$response = $client->request( 'POST', $url, $request_data );
$response_data = json_decode( $response->getBody(), true );
return $response_data;

 

 

And this is the response I obtain. As you can see, the "options" property containing data about the experiences is missing:

 

Array
(
    [status] => 200
    [requestId] => ID
    [client] => CLIENT_NAME
    [id] => Array
        (
            [tntId] => TNT_ID
        )

    [edgeHost] => mboxedge37.tt.omtrdc.net
    [prefetch] => Array
        (
            [mboxes] => Array
                (
                    [0] => Array
                        (
                            [index] => 1
                            [name] => self::ADOBE_TARGET_MBOX_SCOPE1
                            [state] => STATE
                        )

                    [1] => Array
                        (
                            [index] => 2
                            [name] => self::ADOBE_TARGET_MBOX_SCOPE2
                            [state] => STATE
                        )

                )

        )

    [telemetryServerToken] => TELEMETRY_TOKEN
    [execute] => Array
        (
            [mboxes] => Array
                (
                    [0] => Array
                        (
                            [index] => 1
                            [name] => self::ADOBE_TARGET_MBOX_SCOPE1
                        )

                    [1] => Array
                        (
                            [index] => 2
                            [name] => self::ADOBE_TARGET_MBOX_SCOPE2
                        )

                )

        )

)

 

 

What am I possibly doing wrong?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

It's the same idea as this serverState example, with a hybrid implementation, where you have the option to pre-fetch and cache many different offers/activities. That means you can then render them from the cache instead of having to make another network request to Target. 

View solution in original post

21 Replies

Avatar

Correct answer by
Employee Advisor

It's the same idea as this serverState example, with a hybrid implementation, where you have the option to pre-fetch and cache many different offers/activities. That means you can then render them from the cache instead of having to make another network request to Target.