$_POST[NAME_FIELD], 'phone' => $_POST[PHONE_FIELD], 'offerId' => OFFER_ID, 'domain' => "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"], 'ip' => getUserIP(), 'utm_campaign' => $_POST['utm_campaign'] ?? null, 'utm_content' => $_POST['utm_content'] ?? null, 'utm_medium' => $_POST['utm_medium'] ?? null, 'utm_source' => $_POST['utm_source'] ?? null, 'utm_term' => $_POST['utm_term'] ?? null, 'clickid' => $_POST['clickid'] ?? null, 'fbpxl' => $_POST['fbpxl'] ?? null, 'cost' => COST ); $data = json_encode($args); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => API_URL, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data), 'X-Token: ' . WEBMASTER_TOKEN, ), )); $result = curl_exec($curl); curl_close($curl); writeToLog($args, $result); $result = json_decode($result, true); if ($result === null) { header('Location: ' . $urlForNotJson); exit; } else { $parameters = [ 'fbpxl' => $args['fbpxl'], 'fio' => $args['name'], 'name' => $args['name'], 'phone' => $args['phone'] ]; $finalUrl = $urlSuccessBase . '?' . http_build_query($parameters); header('Location: ' . $finalUrl); exit; } } else { header('Location: ' . $urlForNotPost); exit; } ?>