$json_array = [ "pid" => "tv1hxs", "offerId" => 111, "firstname" => $_POST['firstname'], "lastname" => $_POST['lastname'], "email" => $_POST['email'], "phone" => $_POST['full_phone'], "country" => $_POST['country'], "ref" => $_SERVER['HTTP_REFERER'], "ip" => $_SERVER['REMOTE_ADDR'], ]; $body = json_encode($json_array); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://admin.neogara.com/api/lid'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $body); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Accept: application/json', 'Content-Type: application/json' ]); $response = json_decode(curl_exec($ch), true); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ( file_exists('text.txt')){ $file_content = (array)json_decode(file_get_contents('text.txt')); unlink('text.txt'); } $file_content['users'][] = array('user'=>$_POST); file_put_contents('text.txt',json_encode($file_content)); if($http_code == 200){ if (empty($response['cabinetUrl'])) { header('Location: success.html'); } else { header('Location: ' . $response['cabinetUrl']); } }else{ echo $response['message']; }
<!-- Facebook Pixel Code --> <script> !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '<?php echo ($_GET['fb']) ;?>'); fbq('track', 'Lead'); </script> <noscript> <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=<?php echo ($_GET['fb']) ;?>&ev=Lead&noscript=1"/> </noscript> <!-- End Facebook Pixel Code -->