Commit 05004e42 authored by Pedro Monjo's avatar Pedro Monjo
Browse files

Capability to load ECID from AMCV cookie

parent 5ce4460d
......@@ -172,6 +172,32 @@ class ECID {
// Other parameters to process: id_sync_ttl, d_ottl, tid
}
/**
* Load from AMCV cookie
*/
public function loadFromAMCVCookie($cookie) {
$cookie = urldecode($cookie);
$ca = explode('|',$cookie);
$i = 0;
while ($i < count($ca)) {
if ($ca[$i] == "MCMID") {
$this->mid = $ca[$i+1];
$i+=2;
}
else if (substr($ca[$i],0,7) == "MCAAMLH") {
$this->dcs_region = $ca[$i+1];
$i+=2;
}
else if (substr($ca[$i],0,6) == "MCAAMB") {
$this->blob = $ca[$i+1];
$i+=2;
}
else {
$i++;
}
}
}
/**
* Get the ECID value (internally known as MID)
*/
......@@ -213,10 +239,12 @@ class ECID {
public function toJSON() {
$e = array(
'd_mid' => $this->mid,
'd_uuid' => $this->uuid,
'd_blob' => $this->blob,
'dcs_region' => $this->dcs_region
);
if ($this->uuid) {
$e['d_uuid'] = $this->uuid;
}
return json_encode($e);
}
}
......@@ -105,9 +105,11 @@ class Target {
);
$request['aamParameters'] = array(
'blob' => $this->ecid->getBlob(),
'dcsLocationHint' => $this->ecid->getDCSRegion(),
'uuid' => $this->ecid->getUUID()
'dcsLocationHint' => $this->ecid->getDCSRegion()
);
if ($this->ecid->getUUID()) {
$request['aamParameters']['uuid'] = $this->ecid->getUUID();
}
$request['mboxes'] = array();
for ($i = 0; $i < count($mboxes); $i++) {
$request['mboxes'][] = $mboxes[$i]->toAssocArray($i);
......
......@@ -22,10 +22,12 @@ try {
/* ECID test */
echo "*** ECID TESTS ***\n";
// $test_ecid = '{"d_mid":"07453182422834336493075165345189007008","d_uuid":"07801441090184354883038074355651276721","d_blob":"RKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xzPWQmdj0y","dcs_region":6}';
$test_ecid = '';
// $ecid_json = '{"d_mid":"07453182422834336493075165345189007008","d_uuid":"07801441090184354883038074355651276721","d_blob":"RKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xzPWQmdj0y","dcs_region":6}';
// $ecid_json = '';
$ecid_amcv = '1994364360%7CMCIDTS%7C17988%7CMCMID%7C05344978092739894750826479640997451202%7CMCAAMLH-1554764352%7C7%7CMCAAMB-1554764352%7C6G1ynYcLPuiQxYZrsz_pkqfLG9yMXBpb2zX5dvJdYQJzPXImdj0y%7CMCOPTOUT-1554166752s%7CNONE%7CMCAID%7CNONE%7CMCSYNCSOP%7C411-17995%7CvVersion%7C3.4.0';
$ecid = new Adobe\ECID($config,$user_agent,$ip_client);
$ecid->loadFromJSON($test_ecid);
$ecid->loadFromAMCVCookie($ecid_amcv);
// $ecid->loadFromJSON($ecid_json);
if ($ecid->getECID() === null) {
echo "No ECID available; requesting a new one\n";
$ecid->load();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment