andeedee / gapi-google-analytics-php-interface

Automatically exported from code.google.com/p/gapi-google-analytics-php-interface
0 stars 0 forks source link

Fatal error: Uncaught exception 'Exception' with message 'GAPI: Failed to request account data. #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I am using the GAPI Library with AuthSub using PHP curl.

What is the expected output? What do you see instead?
It does not return  the real value of the token.

Instead, it gives me the following fatal error:
*Fatal error*: *Uncaught exception 'Exception' with message 'GAPI: Failed 
to
> request account data.*
> Error: " *Token invalid Token invalid Error 401* "' in /var/www/vhosts/
> kpmrs.com/httpdocs/gapi/gapi.class.php:92 Stack trace: #0 
/var/www/vhosts/
> kpmrs.com/httpdocs/gapi/request_token.php(25): gapi->requestAccountData() 
#1
> {main} thrown in */var/www/vhosts/kpmrs.com/httpdocs/gapi/gapi.class.php* 
on
> line *92*
>

What version of the product are you using? On what operating system?
I am  using GAPI1.3 and on  Windows XP

Please provide any additional information below.
The code that I am using is :

<?php
>
> $url="https://www.google.com/accounts/AuthSubSessionToken";
>
> $header[]='Content-Type: application/x-www-form-urlencoded';
> $header[]='Authorization: AuthSub token="token-Id"';
> $header[]='User-Agent: Java/1.5.0_06';
> $header[]='Host:https://www.google.com';
> $header[]='Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2';
> $header[]='Connection: keep-alive';
>
>   $curl = curl_init();
>   curl_setopt($curl, CURLOPT_URL, $url);
>   curl_setopt($curl, CURLOPT_USERAGENT, 'Java/1.5.0_06');
>   curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
>   curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com');
>   curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
>   curl_setopt($curl, CURLOPT_AUTOREFERER, true);
>   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
>   curl_setopt($curl, CURLOPT_TIMEOUT, 10);
>
>   $html = curl_exec($curl); // execute the curl command
>   curl_close($curl); // close the connection
>
> print_r($html)
> ?>

It will be gret if you can help.
Thanks

Original issue reported on code.google.com by dimpeede...@gmail.com on 22 Aug 2009 at 2:09

GoogleCodeExporter commented 9 years ago
Im encountering the same problem. Im using windows xp php 5.2.6
I removed the actual email and password. Thanks
Code is: 

<?php
define('ga_email','xxx@gmail.com');
define('ga_password','xxx');
define('ga_profile_id','xxx');

require 'gapi.class.php';

$ga = new gapi(ga_email,ga_password);

$ga->requestReportData(ga_profile_id,array('browser','browserVersion'),array('pa
geviews','visits'));
?>
<table>
<tr>
  <th>Browser & Browser Version</th>
  <th>Pageviews</th>
  <th>Visits</th>
</tr>
<?php
foreach($ga->getResults() as $result):
?>
<tr>
  <td><?php echo $result ?></td>
  <td><?php echo $result->getPageviews() ?></td>
  <td><?php echo $result->getVisits() ?></td>
</tr>
<?php
endforeach
?>
</table>

<table>
<tr>
  <th>Total Results</th>
  <td><?php echo $ga->getTotalResults() ?></td>
</tr>
<tr>
  <th>Total Pageviews</th>
  <td><?php echo $ga->getPageviews() ?>
</tr>
<tr>
  <th>Total Visits</th>
  <td><?php echo $ga->getVisits() ?></td>
</tr>
<tr>
  <th>Results Updated</th>
  <td><?php echo $ga->getUpdated() ?></td>
</tr>
</table>

Original comment by thumbint...@gmail.com on 8 Sep 2009 at 11:01

GoogleCodeExporter commented 9 years ago
Same here. Did Google change anything that broke compatibility with GAPI 1.3?

Original comment by projektz...@googlemail.com on 19 Sep 2009 at 11:31

GoogleCodeExporter commented 9 years ago
Had the same problem, my account ID was wrong. I got the right one with the 
sample
code "example.account.php" and now it works!

Original comment by antti...@gmail.com on 15 Oct 2009 at 10:07

GoogleCodeExporter commented 9 years ago
Thanks very much to commenter #3. Worked perfectly!! Much appreciated.

Original comment by samala...@gmail.com on 24 Apr 2011 at 3:41

GoogleCodeExporter commented 9 years ago
comment 3 did not help me out. Google passes back the Request token but gapi 
seems to have problems using it.

I even tried stripping out the 1/ at the start of the token... still same 
results.

If I cant use a request token provided by google to turn around and request a 
access token to store into database then I can't use use :(

Note: the user was directed to google with this
-------------
https://www.google.com/accounts/AuthSubRequest?next=<?=$type?>://<?=$_SERVER["HT
TP_HOST"]?>
/?scope=https://www.google.com/analytics/feeds/&secure=0&session=1
-------------

-code-
$ga = new gapi(null,null,'1/-WcoNQJc7EJ702f56Jb4t0TV0lW89po1Zy0AdkyS0PY');

-Result- 
Fatal error: Uncaught exception 'Exception' with message 'GAPI: Failed to 
request account data. Error: " Token invalid Token invalid Error 401 "' in 

Original comment by Tony.Fre...@gmail.com on 25 Apr 2011 at 9:15

GoogleCodeExporter commented 9 years ago
I got the same problem now, when i was pushed by google to migrate my adwords 
account to a different one due to conflict with my google apps account.

Sollution was to go to https://www.google.com/accounts/DisplayUnlockCaptcha and 
unlock the new email using captcha

Original comment by kap...@mediacentrum.cz on 27 Apr 2011 at 8:16

GoogleCodeExporter commented 9 years ago
But in this code ....Can i display the chart (view visitors) ??

Original comment by barotvis...@gmail.com on 7 Oct 2011 at 1:13

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Are the developers of the script aware of that MAIN issue/securityrisk this 
error shows both email-address and password fully visible for the visitor if 
user of the script use 2-step verification and haven't changed GAPI to use the 
"script-specific" password??
With a Google-search of this error shows tons of theese emails fully visible, 
ready to to be hacked

Original comment by nordicwe...@gmail.com on 4 Dec 2011 at 8:16

GoogleCodeExporter commented 9 years ago
Please help me, i've got same problem. Please help me know what is 
ga_profile_id?
Is it Property ID: UA-1145xxx-16 ?

Original comment by quangtam...@gmail.com on 14 Jun 2012 at 5:25

GoogleCodeExporter commented 9 years ago
for anybody still using GAPI - I've found what was causing this in my case. You 
need to update The OpenSearch namespace - read here at the bottom:

https://developers.google.com/gdata/docs/developers-guide

it's in 2 places in gapi - just replace http://a9.com/-/spec/opensearchrss/1.0/ 
with http://a9.com/-/spec/opensearch/1.1/

hope this helps - took me an hour to find that....

Original comment by slawek.n...@gmail.com on 25 Jul 2012 at 8:48

GoogleCodeExporter commented 9 years ago
Need help!! :( Same error, no fixing TRIED ALL!!

Original comment by ad...@fedevarer.dk on 27 Aug 2012 at 8:45

GoogleCodeExporter commented 9 years ago
Fatal error: Uncaught exception 'Exception' with message 'GAPI: Failed to 
authenticate user. Error: ""' in /var/www/tools/gapi.class.php:421 Stack trace: 
#0 /var/tools/gapi.class.php(65): gapi->authenticateUser('abc@gmail...', 
'@abc123@') #1 /var/tools/transaction_report.php(37): 
gapi->__construct('abc@gmail...', '@abc123@') #2 {main} thrown in 
/var/tools/gapi.class.php on line 421

Original comment by kapilver...@gmail.com on 28 Nov 2014 at 11:10