From 4445af89bcbea944a7606af9ea4d537db5009fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondrej=20Podolinsk=C3=BD?= Date: Mon, 20 Jan 2014 15:55:36 +0100 Subject: [PATCH] Added api_key for additional authentication If you are using import events older than 5 days at /import endpoint, api_key is added at the end of data base64 encoded string. --- lib/ConsumerStrategies/CurlConsumer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ConsumerStrategies/CurlConsumer.php b/lib/ConsumerStrategies/CurlConsumer.php index aea72a3..c39fe02 100644 --- a/lib/ConsumerStrategies/CurlConsumer.php +++ b/lib/ConsumerStrategies/CurlConsumer.php @@ -35,6 +35,11 @@ class ConsumerStrategies_CurlConsumer extends ConsumerStrategies_AbstractConsume */ protected $_fork = null; + /** + * @var string|null additional verification for endpoint /import + */ + protected $_api_key; + /** * Creates a new CurlConsumer and assigns properties from the $options array @@ -49,6 +54,7 @@ function __construct($options) { $this->_timeout = array_key_exists('timeout', $options) ? $options['timeout'] : 1; $this->_protocol = array_key_exists('use_ssl', $options) && $options['use_ssl'] == true ? "https" : "http"; $this->_fork = array_key_exists('fork', $options) ? ($options['fork'] == true) : false; + $this->_api_key = array_key_exists('api_key', $options) ? $options['api_key'] : null; // ensure the environment is workable for the given settings if ($this->_fork == true) { @@ -100,6 +106,10 @@ protected function _execute($url, $data) { $this->_log("Making blocking cURL call to $url"); } + if(!is_null($this->_api_key)){ + $data .= '&api_key='.$this->_api_key; + } + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); @@ -144,4 +154,4 @@ protected function _execute_forked($url, $data) { return $return_var == 0; } -} \ No newline at end of file +}