Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. error_reporting(85);
  3. header("Content-Type: text/html; charset=UTF-8");
  4.  
  5.  
  6. $api_data = array(
  7. "offer_id" => 1306,
  8. "api_key" => "b655922bee4a4dc5",
  9. "name" => trim($_POST['name']),
  10. "phone" => trim($_POST['phone']),
  11. "country" =>(trim($_POST['country'])?:"ru"),
  12. "ip" => $_SERVER['REMOTE_ADDR'],
  13. "host" => $_SERVER['HTTP_HOST'],
  14. );
  15.  
  16.  
  17.  
  18. function curl($url, $post, $headers){
  19. $ch = curl_init();
  20.  
  21. curl_setopt($ch, CURLOPT_URL, $url);
  22. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  23. if($post){curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post);}
  24. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  25.  
  26. $rez = curl_exec($ch);
  27. curl_close($ch);
  28.  
  29. return $rez;
  30. }
  31.  
  32.  
  33. if(trim($_POST['name'])&&trim($_POST['phone'])){
  34. $api_z = json_decode(curl("http://cpagetti.com/api/order/register", http_build_query($api_data)), true);
  35. if($_GET['var_dump']=="api"){var_dump($api_data); var_dump($api_z); exit;}
  36.  
  37. if($api_z['success']){
  38. header("Location: success.html"); exit;
  39. }else{echo "error".(($api_z['message'])?": ".$api_z['message']:"");}
  40. }else{echo "name and phone required";}
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement