Advertisement
Guest User

Untitled

a guest
Oct 4th, 2018
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 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.  
  14. $success = true;
  15. $offset = 0;
  16.  
  17. while($success){
  18.     $jsonObj = array(
  19.                 'from' => '2018-10-04 10:00:00',
  20.                 'to' => date('Y-m-d H:i:s'),
  21.                 'type' => '3',
  22.                 "offset" => $offset
  23.                 );
  24.  
  25.     try{
  26.             $curl = curl_init($url);
  27.  
  28.             curl_setopt_array($curl, array(
  29.                 CURLOPT_RETURNTRANSFER => 1,
  30.                 CURLOPT_POST => 1,
  31.                 CURLOPT_HTTPHEADER => array("x-trackbox-username:".$username, "x-trackbox-password:".$password, "x-api-key:".$key, "Content-type:application/json"),
  32.                 CURLOPT_POSTFIELDS => json_encode($jsonObj),
  33.             ));
  34.             $result = curl_exec($curl);
  35.             print_r($result);
  36.  
  37.             if (FALSE === $result)
  38.                   throw new Exception(curl_error($curl), curl_errno($curl));
  39.  
  40.         }catch(Exception $e) {
  41.  
  42.           trigger_error(sprintf(
  43.               'Curl failed with error #%d: %s',
  44.               $e->getCode(), $e->getMessage()),
  45.               E_USER_ERROR);
  46.  
  47.       }
  48.             echo '<pre>';
  49.             //print_r($result);
  50.             $resp = json_decode($result);
  51.         //    print_r($resp);
  52.             if($resp->status){
  53.                 $data = $resp->data;
  54.                 //print_r($data);
  55.                 if(is_array($data)){
  56.                     if(count($data) > 0){
  57.                         foreach($data as $info){
  58.                             $customerData = $info->customerData;
  59.                             //print_r($customerData); exit;
  60.                             $email = $customerData->email;
  61.                             $firstname = $customerData->firstname;
  62.                             $lastname = $customerData->lastname;
  63.                             $phone = $customerData->phone;
  64.                             $country = $customerData->countrcode;
  65.                             $ip = $customerData->ip;
  66.                             $firstDepositDate = $customerData->first_depositDate;
  67.                             $created_date = $customerData->created;
  68.                             echo "<br />".$email." ".$firstname." ".$lastname." ".$phone." ".$country." ".$ip." ".$created_date."-->".$firstDepositDate;
  69.  
  70.  
  71.  
  72.                         }
  73.                         $offset += 500;
  74.                     }else{
  75.                         $success = false;
  76.                     }
  77.  
  78.                 }
  79.  
  80.             }else{
  81.                 echo "Error fetching leads";exit;
  82.             }
  83. }
  84.  
  85.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement