Advertisement
Guest User

leadbit_api

a guest
Jan 20th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.04 KB | None | 0 0
  1. <?php
  2.  
  3. const API = '4c24536a4c7c325743526d25636c7b47';
  4. const API_URL      = "http://leadbit.com/api/new-order/" . API;
  5.  
  6. const FLOW_HASH = 'gjjV'; // хеш потока
  7. const LANDING = 'http://th5.forfun.maxisize-pro.com';
  8. const COUNTRY = 'TH';
  9. $fbpixel          = $_REQUEST['fbp'] ? $_REQUEST['fbp'] : 0;
  10.  
  11. $isCurlEnabled = function () {
  12.     return function_exists( 'curl_version' );
  13. };
  14.  
  15. if ( ! $isCurlEnabled ) {
  16.     echo "<pre>";
  17.     echo "pls install curl\n";
  18.     echo "For *unix open terminal and type this:\n";
  19.     echo 'sudo apt-get install curl && apt-get install php-curl';
  20.     die;
  21. }
  22.  
  23. $args = [
  24.     'flow_hash' => FLOW_HASH,
  25.     'landing' => LANDING,
  26.     'phone' => $_REQUEST['phone'],
  27.     'name' => $_REQUEST['name'],
  28.     'country' => COUNTRY,
  29.     'referrer' => isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "",
  30.     'sub1' => $_REQUEST['subid1'],
  31.     'sub2' => $_REQUEST['subid2'],
  32.     'sub3' => $_REQUEST['subid3'],
  33.     'sub4' => $_REQUEST['subid4'],
  34.     'sub5' => $_REQUEST['subid5'],
  35. ];
  36.  
  37. $curl = curl_init();
  38. curl_setopt_array( $curl, array(
  39.     CURLOPT_URL            => API_URL,
  40.     CURLOPT_POST           => true,
  41.     CURLOPT_POSTFIELDS     => $args,
  42.     CURLOPT_RETURNTRANSFER => true
  43. ) );
  44. $res = curl_exec( $curl );
  45. curl_close( $curl );
  46.  
  47. $res               = json_decode( $res, true );
  48. if ( $res['status'] !== 'fail' ) {
  49.     ?>
  50.     <!doctype html>
  51.     <html lang="en">
  52.     <head>
  53.         <meta charset="UTF-8">
  54.         <meta name="viewport"
  55.               content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  56.         <meta http-equiv="X-UA-Compatible" content="ie=edge">
  57.         <title style="text-align: center">Your order is accepted!</title>
  58.         <?php if($fbpixel !== 0) : ?>
  59.         <!-- Facebook Pixel Code -->
  60.         <script>
  61.             !function (f, b, e, v, n, t, s) {
  62.                 if (f.fbq)return;
  63.                 n = f.fbq = function () {
  64.                     n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments)
  65.                 }
  66.                 ;
  67.                 if (!f._fbq) f._fbq = n;
  68.                 n.push = n;
  69.                 n.loaded = !0;
  70.                 n.version = '2.0';
  71.                 n.queue = [];
  72.                 t = b.createElement(e);
  73.                 t.async = !0;
  74.                 t.src = v;
  75.                 s = b.getElementsByTagName(e)[0];
  76.                 s.parentNode.insertBefore(t, s)
  77.             }(window,
  78.                 document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
  79.             fbq('init', <?php echo $fbpixel; ?>); // Insert your pixel ID here.
  80.             fbq('track', 'PageView');
  81.         </script>
  82.         <noscript><img height="1" width="1" style="display:none"
  83.                        src="https://www.facebook.com/tr?id=<?php echo $fbpixel; ?>&ev=PageView&noscript=1"
  84.             /></noscript>
  85.         <!-- DO NOT MODIFY -->
  86.         <!-- End Facebook Pixel Code -->
  87.     <?php endif;?>
  88.     </head>
  89.     <body>
  90.     <?php if($fbpixel !== 0) : ?>
  91.     <script>
  92.         fbq('track', 'Lead');
  93.     </script>
  94.     <?php endif;?>
  95.     <h1>Your order is accepted!</h1>
  96.     </body>
  97.     </html>
  98.     <?php
  99. } else {
  100.     var_dump($res);
  101. }
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement