'3_SrvinAwcHMg05QGOhREjngdgRrclNvu1QtR2KlQ1nb98EOqlU9RBE2bWahdWAmUe', 'userKey' => 'ANaom8ZjBnR/', 'secret' => 'ABzcBnIRwcQVz/WxHKDA4jHh2DAwikoD' ); $GLOBALS['formData'] = $_POST; echo "form data:
"; print_r($_POST); echo "

"; getRegToken(); function getRegToken(){ $url = "https://accounts.eu1.gigya.com/accounts.initRegistration"; $params = $GLOBALS['params']; $params['isLite'] = true; $params_string = http_build_query($params); $response = MakeCDCRequest($params_string,$url); $json = json_decode($response, true); echo "initRegistration response:
"; print_r($response); echo "

"; if($json['errorCode'] === 0) { $regToken = $json['regToken']; setAccountInfo($regToken); } } function setAccountInfo($regToken){ $params = $GLOBALS['params']; $formData = $GLOBALS['formData']; $profile = array(); $subscriptions = array(); $preferences = array(); foreach($formData as $key => $value) { $keyArray = explode("~", $key); switch($keyArray[0]){ case "profile": $profile[$keyArray[1]] = $value; break; case "subscriptions": //$newKey = str_replace("subscriptions~","",$key); $subscriptions[$keyArray[1]] = array( 'email' => array( 'isSubscribed' => true ) ); break; case "preferences": switch($keyArray[1]){ case "terms": $preferences['terms'] = array( $keyArray[2] => array( 'isConsentGranted' => true ) ); break; case "privacy": $preferences['privacy'] = array( $keyArray[2] => array( 'isConsentGranted' => true ) ); break; } break; } }; $params['regToken'] = $regToken; $params['profile'] = json_encode($profile); $params['subscriptions'] = json_encode($subscriptions); $params['preferences'] = json_encode($preferences); $params['lang'] = 'en'; $params['context'] = json_encode($formData); $params_string = http_build_query($params); $url = "https://accounts.eu1.gigya.com/accounts.setAccountInfo"; $response = MakeCDCRequest($params_string, $url); echo "setAccountInfo response:
"; print_r($response); echo "

"; $json = json_decode($response, true); if($json['errorCode'] === 0) { $UID = $json['UID']; dsStore($UID); } } function dsStore($uid){ $params = $GLOBALS['params']; $formdata = $GLOBALS['formData']; $data = array(); foreach($formdata as $key => $value) { $key = str_replace("~","_",$key); $data[$key] = $value; }; $data['UID'] = $uid; $params['data'] = json_encode($data); $params['type'] = $data['brand']; unset($$data['brand']); $params['oid'] = "auto"; $params_string = http_build_query($params); $url = "https://ds.eu1.gigya.com/ds.store"; $response = MakeCDCRequest($params_string, $url); echo "ds.store response:
"; print_r($response); } function MakeCDCRequest($paramsString, $url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $paramsString); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); $call = curl_getinfo($curl); $response = curl_exec($curl); echo "Make CDC request call:
"; print_r($call); echo "

"; curl_close($curl); return $response; } ?>