PHP and Adobe Target Delivery API | Community
Skip to main content
Level 3
November 23, 2023
Solved

PHP and Adobe Target Delivery API

  • November 23, 2023
  • 1 reply
  • 5271 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by alexbishop

Thanks again!

One more question: why am I getting a "state" attribute with some kind of encrypted value as part of the response of the "mbox"? By checking this link, I don't see the "state" anywhere. I mean something like this:

[prefetch] => Array ( [mboxes] => Array ( [0] => Array ( [index] => 1 [name] => [mbox_name] [state] => [state] ) ) )

 


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. 

1 reply

alexbishop
Adobe Employee
Adobe Employee
November 23, 2023

If you don't have the options array included as part of the response, it's typically because you're not qualifying for any Target activities. How is your activity set up in Target? A/B test using Form Composer with an mbox name that matches one of the two you are including in your request?

PedroFiAuthor
Level 3
November 23, 2023

Thanks, @alexbishop 

Yes, my activity is using Form Composer with an mbox name that matches the one in my request. However, the activity is not active yet. Should I include "qaMode" in my request? 

alexbishop
Adobe Employee
Adobe Employee
November 23, 2023

Ah ok, yes that explains why you don't get the options response; if an activity is not active, you can only qualify for it by using that QA URL option and including that full query string in your request