示例#1
0
 public function __construct()
 {
     // Get ENV values for API Key and Customer keys is defined
     if (isset($_ENV['TRAACKR_API_KEY'])) {
         TraackrApi::setApiKey($_ENV['TRAACKR_API_KEY']);
     }
     if (isset($_ENV['TRAACKR_CUSTOMER_KEY'])) {
         TraackrApi::setCustomerKey($_ENV['TRAACKR_CUSTOMER_KEY']);
     }
     if (isset($_ENV['TRAACKR_API_URL'])) {
         self::$apiBaseUrl = $_ENV['TRAACKR_API_URL'];
     }
     if (strrpos(self::$apiBaseUrl, '/') !== strlen(self::$apiBaseUrl) - 1) {
         self::$apiBaseUrl .= '/';
     }
 }
 public function delete($url, $params = array())
 {
     // Build Parameters
     // Add API key parameter if not present
     $api_key = TraackrApi::getApiKey();
     if (!isset($params[PARAM_API_KEY]) && !empty($api_key)) {
         $params[PARAM_API_KEY] = $api_key;
     }
     // API key always passed as a query string even for POST
     if (!empty($params[PARAM_API_KEY])) {
         $url .= "?" . PARAM_API_KEY . '=' . $params[PARAM_API_KEY];
     }
     // Sets URL
     curl_setopt($this->curl, CURLOPT_URL, $url);
     // Prepare and set params
     $params = $this->prepareParameters($params);
     $http_param_query = http_build_query($params);
     curl_setopt($this->curl, CURLOPT_POSTFIELDS, $http_param_query);
     // Sets URL
     curl_setopt($this->curl, CURLOPT_URL, $url);
     // Set Custom Request for DELETE
     curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
     // Make call
     $logger = TraackrAPI::getLogger();
     $logger->debug('Calling (DELETE): ' . $url);
     return $this->call(!TraackrAPI::isJsonOutput());
 }