Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. error_reporting(E_ALL);
  4. $username = "M_DE_NORDIC_VIT";
  5. $password = "123456NC";
  6.  
  7. $url = "https://platform.trackbox.com/api/pull/customers";
  8.  
  9. $key = "264388973aaa9b2f9eb2aa84a9c7382e";
  10.  
  11. $jsonObj = array(
  12.             'from' => '2018-01-01 00:00:00',
  13.             'to' => '2018-01-31 00:00:00',
  14.             'type' => '2'
  15.             );
  16.  
  17. try{
  18.         $curl = curl_init($url);
  19.  
  20.  
  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.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement