wanze / google-analytics-api-php Goto Github PK
View Code? Open in Web Editor NEWSimple class to query the Google Analytics API v3 with PHP
Simple class to query the Google Analytics API v3 with PHP
Hi! Thank you for your work. Im using your library, but i found an issue. The metric ga:visits is not in use. It has been change for ga:sessions.
Thank you!
Regards, Francisco Redondo
Hello,
I am having the same issue as mahony0, where the script is throwing back :
var_dump($ga) returns :
object(GoogleAnalyticsAPI) (5) {
["auth"]=>
object(GoogleOauthService) (5) {
["email":protected]=>
string(75) "[email protected]"
["privateKey":protected]=>
string(55) "XXXXX-privatekey.p12"
["password":protected]=>
string(10) "notasecret"
["assoc":protected]=>
bool(true)
["clientId":protected]=>
string(72) "874775054712- XXXXX.apps.googleusercontent.com"
}
["accessToken":protected]=>
string(0) ""
["accountId":protected]=>
string(0) ""
["assoc":protected]=>
bool(true)
["defaultQueryParams":protected]=>
array(3) {
["start-date"]=>
string(10) "2013-10-11"
["end-date"]=>
string(10) "2013-11-11"
["metrics"]=>
string(9) "ga:visits"
}
}
Fatal error: Uncaught exception 'Exception' with message 'You must provide an accessToken' in /home/ftp/XXXXX/GoogleAnalyticsAPI.class.php:162
Stack trace:
/home/ftp/XXXXX/test2.php(29): GoogleAnalyticsAPI->getProfiles()
{main}
thrown in /home/ftp/XXXXX/GoogleAnalyticsAPI.class.php on line 162
and $auth = $ga->auth->getAccessToken();
print_r($auth) returns :
Array
(
[http_code] => 200
[access_token] => ya29.AHES6ZRZR2DkYIs5MvKEiLhtXXXXXXX1d1o1hmg
[token_type] => Bearer
[expires_in] => 3600
)
I tried the work around with the curl function but still the same issue, not sure why this issue occurs as I am getting an access token. I tried on a php 5.4 and 5.3 version same issue.
What do you think is the issue here? Let me know if you need more info to try to tackle this issue.
Thanks.
Hey there, here's the error I'm receiving when using the basic example:
Sorry, something wend wrong retrieving the oAuth tokens
I've entered my credentials as according to API Console and for some reason I'm not getting an access token.
Does it work with the Multi-Channel Funnels requests ?
// Example5: Get referral traffic
$referralTraffic = $ga->getRefferralTraffic();
should be named as in class
getReferralTraffic($params=array()) {
Since 22th october, I keep getting "ERROR connecting to Analytics API".
Everything was working fine since months, and I did not change anything.
Any idea how to debug this ?
Thanks...
I'm getting this after trying to run my script:
Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are >required to use the date.timezone setting or the date_default_timezone_set() >function. In case you used any of those methods and you are still getting this >warning, you most likely misspelled the timezone identifier. We selected >'Europe/Berlin' for 'CEST/2.0/DST' instead in >/path/to/GoogleAnalytics>API.class.php on line 68```
Warning: date(): It is not safe to rely on the system's timezone settings. You are >required to use the date.timezone setting or the date_default_timezone_set() >function. In case you used any of those methods and you are still getting this >warning, you most likely misspelled the timezone identifier. We selected >'Europe/Berlin' for 'CEST/2.0/DST' instead in >/path/to/GoogleAnalyticsAPI.class.php on line 68
php -v
PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Maybe a default timezone with a 'global' variable should be enough.
Great class anyway :)
##1. Basic Setup
Create a Project in the Google APIs Console: https://code.google.com/apis/console/
Enable the Analytics API under Services
Under API Access: Create an Oauth 2.0 Client-ID
Give a Product-Name, choose Web Application or Service Account depending on your needs
Web Application: Set a redirect-uri in the project which points to your apps url
Service Account: Download the private key (.p12 file)
when someone person login with google , after login i want there account id , web property id and view id auto.
please help me how can i fetch there Analytics id , beacuse i want every user see there Analytices deatils after login.
thanks
I am using service account method to auth, but even if everything is correct, I got an error after call $ga->auth->getAccessToken();
.
The http_code is 400, and I got the error invalid_grant
.
Is there something else to do ?
Ok just my server clock was not set properly.
Hi,
I am running this script in my local machine with 127.0.0.1 URL but I am getting below URL:
Sorry, something wend wrong retrieving the oAuth tokens
Please guide me to resolve this error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.