Advertisement
Guest User

trackbox pull request

a guest
Aug 29th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.16 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. error_reporting(E_ALL);
  4. $username = "Nimrod";
  5. $password = "Orco2010";
  6.  
  7. $url = "https://platform.trafficoni.com/api/pull/customers";
  8.  
  9. $key = "264388973aaa9b2f9eb2aa84a9c7382e";
  10.  
  11. $sourceId=26;
  12.  
  13. $jsonObj = array(
  14.             'from' => '2018-01-01 00:00:00',
  15.             'to' => date('Y-m-d H:i:s'),
  16.             'type' => '3'
  17.             );
  18.  
  19. try{
  20.         $curl = curl_init($url);
  21.  
  22.         curl_setopt_array($curl, array(
  23.             CURLOPT_RETURNTRANSFER => 1,
  24.             CURLOPT_POST => 1,
  25.             CURLOPT_HTTPHEADER => array("x-trackbox-username:".$username, "x-trackbox-password:".$password, "x-api-key:".$key, "Content-type:application/json"),
  26.             CURLOPT_POSTFIELDS => json_encode($jsonObj),
  27.         ));
  28.         $result = curl_exec($curl);
  29.  
  30.         if (FALSE === $result)
  31.               throw new Exception(curl_error($curl), curl_errno($curl));
  32.  
  33.     }catch(Exception $e) {
  34.  
  35.       trigger_error(sprintf(
  36.           'Curl failed with error #%d: %s',
  37.           $e->getCode(), $e->getMessage()),
  38.           E_USER_ERROR);
  39.  
  40.   }
  41.         echo '<pre>';
  42.         print_r($result);
  43.         $resp = json_decode($result);
  44.         //print_r($resp);
  45.         if($resp->status){
  46.             $data = $resp->data;
  47.             //print_r($data);
  48.             /*if(is_array($data)){
  49.                 foreach($data as $info){
  50.                     $customerData = $info->customerData;
  51.                     print_r($customerData); exit;
  52.                     $email = $customerData->email;
  53.                     $firstname = $customerData->firstname;
  54.                     $lastname = $customerData->lastname;
  55.                     $phone = $customerData->phone;
  56.                     $country = $customerData->countrcode;
  57.                     $ip = $customerData->ip;
  58.                     $firstDepositDate = $customerData->first_depositDate;
  59.                     $created_date = $customerData->created;
  60.                     echo "<br />".$email." ".$firstname." ".$lastname." ".$phone." ".$country." ".$ip." ".$created_date;
  61.  
  62.  
  63.  
  64.                 }
  65.             }*/
  66.  
  67.         }else{
  68.             echo "Error fetching leads";exit;
  69.         }
  70.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement