Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Pobieranie danych z Google Analytics z pomocą skryptu php., php Google Analytics gapi
rnest
post 30.10.2014, 15:20:01
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 26.04.2014

Ostrzeżenie: (0%)
-----


Pozdrawiam wszystkich.

Mam problem z pobraniem danych z GA za pomocą skryptu php.

Korzystam z gotowej klasy gapi ->

https://code.google.com/p/gapi-google-analy...s-php-interface

(proszę spacje pousuwać z adresu)

Podczas uruchomienia skryptu lokalnie otrzymuję błąd:

Fatal error: Uncaught exception 'Exception' with message 'GAPI: Failed to authenticate user. Error: "Error=BadAuthentication Url=https://www.google.com/accounts/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtZJYTUg3dFuqdNpJYVABbupauXITr7yA5Q_nibJrVOZ3X32zMgwi66rH6TPDjp4kfs
b0B4Mio5CBF5sZ-iJ6nbaVBg3hRw-joTNHGrIzp-klSWrSQg8NLk3NC7AAt1e37I4aNKGxDinEV5W-YGOzvWBpdovr-ggiTTIO_SB2a2PSQJSyW4sV7lSvYvomuljb942WN9buTby9mrwDn4YHNW4GvJrCxO2twClDnO0enTDgo
Sc8Q Info=WebLoginRequired "' in D:\XAMPP\htdocs\Gapi\gapi-1.3\gapi.class.php:418 Stack trace: #0 D:\XAMPP\htdocs\Gapi\gapi-1.3\gapi.class.php(62): gapi->authenticateUser('___@gmail.com.', '__ZZZZZ') #1 D:\XAMPP\htdocs\Gapi\index.php(16): gapi->__construct('___@gmail.com.', '__ZZZZZ') #2 {main} thrown in D:\XAMPP\htdocs\Gapi\gapi-1.3\gapi.class.php on line 418

Mam założone konto na GA. Ustawione jest śledzenie strony : http://rnest.prohost.pl/gapi/index.php
za pomocą rekomendowanego na stronie GA skryptu js. Niestety po sprawdzeniu stanu śledzenia w zakładce administracja - stan jest : Śledzenie niezainstalowane.

Skrypt do pobierania raportu z GA:

  1.  
  2. require 'gapi-1.3/gapi.class.php';
  3.  
  4. /* Set your Google Analytics credentials */
  5. define('ga_account', 'adres...@gmail.com');
  6. define('ga_password', 'pass...');
  7. define('ga_profile_id', '93191111');
  8.  
  9. $ga = new gapi(ga_account, ga_password);
  10.  
  11. /* We are using the 'source' dimension and the 'visits' metrics */
  12. $dimensions = array('source');
  13. $metrics = array('visits');
  14.  
  15. /* We will sort the result be desending order of visits,
  16.   and hence the '-' sign before the 'visits' string */
  17. $ga->requestReportData(ga_profile_id, $dimensions, $metrics, '-visits');
  18.  
  19. $gaResults = $ga->getResults();
  20.  
  21. $i = 1;
  22.  
  23. foreach ($gaResults as $result) {
  24. printf("%-4d %-40s %5d\n", $i++, $result->getSource(), $result->getVisits());
  25. }
  26.  
  27. echo "\n-----------------------------------------\n";
  28. echo "Total Results : {$ga->getTotalResults()}";
  29.  
  30.  
  31.  


Nie miałem do tej pory do czynienia z GA. Hasło, które podaje do skryptu jest hasłem mojego gmaila + adres email gmail ...

Czy może ktoś ma sugestie jak ten problem rozwiązac?

Go to the top of the page
+Quote Post
redeemer
post 3.11.2014, 22:09:23
Post #2





Grupa: Zarejestrowani
Postów: 915
Pomógł: 210
Dołączył: 8.09.2009
Skąd: Tomaszów Lubelski/Wrocław

Ostrzeżenie: (0%)
-----


Korzystasz w ogóle z jakiejś biblioteki z 2009 roku.

https://github.com/google/google-api-php-client

https://developers.google.com/analytics/sol...o-analytics-api


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.04.2024 - 22:54