From 2acb364552e1ba3184bd18d3541736e9b1ef9219 Mon Sep 17 00:00:00 2001 From: mattab Date: Wed, 23 Apr 2014 18:58:29 +1200 Subject: Fixes #5030 Tracking API now does not require token_auth for bulk requests. To make behavior the same as in Piwik 2.1.0 or earlier, set the following config setting under [Tracker]: ; Whether Bulk tracking requests to the Tracking API requires the token_auth to be set. bulk_requests_require_authentication = 1 --- libs/PiwikTracker/PiwikTracker.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libs/PiwikTracker') diff --git a/libs/PiwikTracker/PiwikTracker.php b/libs/PiwikTracker/PiwikTracker.php index ba790c77b0..a62feb7a8b 100644 --- a/libs/PiwikTracker/PiwikTracker.php +++ b/libs/PiwikTracker/PiwikTracker.php @@ -627,15 +627,16 @@ class PiwikTracker */ public function doBulkTrack() { - if (empty($this->token_auth)) { - throw new Exception("Token auth is required for bulk tracking."); - } - if (empty($this->storedTrackingActions)) { throw new Exception("Error: you must call the function doTrackPageView or doTrackGoal from this class, before calling this method doBulkTrack()"); } - $data = array('requests' => $this->storedTrackingActions, 'token_auth' => $this->token_auth); + $data = array('requests' => $this->storedTrackingActions); + + // token_auth is not required by default, except if bulk_requests_require_authentication=1 + if(!empty($this->token_auth)) { + $data['token_auth'] = $this->token_auth; + } $postData = json_encode($data); $response = $this->sendRequest($this->getBaseUrl(), 'POST', $postData, $force = true); -- cgit v1.2.3