From 5d6f29d2e5f0e110a108a7a29d17a4ff414f08d3 Mon Sep 17 00:00:00 2001 From: Vicente Guerra Date: Thu, 10 Dec 2015 12:02:42 -0600 Subject: [PATCH] Set default time zone , if not configured --- GoogleAnalyticsAPI.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GoogleAnalyticsAPI.class.php b/GoogleAnalyticsAPI.class.php index 2762e44..58a0da2 100644 --- a/GoogleAnalyticsAPI.class.php +++ b/GoogleAnalyticsAPI.class.php @@ -41,6 +41,7 @@ class GoogleAnalyticsAPI { const API_URL = 'https://www.googleapis.com/analytics/v3/data/ga'; const WEBPROPERTIES_URL = 'https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties'; const PROFILES_URL = 'https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles'; + const TIMEZONE = 'America/New_York'; public $auth = null; protected $accessToken = ''; @@ -61,8 +62,10 @@ class GoogleAnalyticsAPI { * @param String $auth (default: 'web') 'web' for Web-applications with end-users involved, 'service' for service applications (server-to-server) */ public function __construct($auth='web') { - if (!function_exists('curl_init')) throw new Exception('The curl extension for PHP is required.'); + if (!ini_get('date.timezone')) { + date_default_timezone_set(self::TIMEZONE); + } $this->auth = ($auth == 'web') ? new GoogleOauthWeb() : new GoogleOauthService(); $this->defaultQueryParams = array( 'start-date' => date('Y-m-d', strtotime('-1 month')),