I find this API references extremly confusing... I dont understand it
very well and looking for examples is VERY HARD all them uses diferent
ways to retreive info, and more confusing ways to distract me, worst
is that just copy and paste them, and run, do not work at all.
how ever... I find this example to "access" the reporting API but as
usuall with the Google API examples, it does not work! any help? lead
to a GOOD and WORKING tutorial to access the Reporting API in PHP ?,
Here's the code that not work (and is taken EXACTLY from the google
documentation pages, with just some changes to get my domain and the
today date)
<?php
$location = "
https://www.google.com/hosted/services/v1.0/reports/
ReportingData";
$xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rest xmlns=\"google:accounts:rest:protocol\"
xmlns:xsi=\"
http://www.w3.org/2001/XMLSchema-instance \">
<type>Report</type>
<domain>MYDOMAIN</domain>
<date>".date('Y-m-d')."</date>
<page>1</page>
<reportType>daily</reportType>
<reportName>accounts</reportName>
</rest>\n";
// Communicate with google checkout
$ch = curl_init ($location);
curl_setopt ($ch, CURLOPT_POST, true); // Use a standard HTTP Post
curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml_response);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); // Return transfer
of the string instead of outputting it directly.
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); // The maximum number of
seconds to allow cURL functions to execute.
curl_setopt ($ch, CURLOPT_SSLVERSION, 3); // Latest SSL version
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); // Don't checkname in
SSL cerfificate
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); // No files holder
certificates to verify
$response = curl_exec ($ch);
if(curl_errno($ch)) {
trigger_error(curl_error($ch), E_USER_ERROR);
}
curl_close ($ch);
echo $response;
?>
And I get this RESPONSE from the google API
<?xml version="1.0" encoding="UTF-8" ?>
<hs:rest xmlns:hs="google:accounts:rest:protocol">
<hs:status>Failure(2001)</hs:status>
<hs:reason>AuthenticationFailure(1006)</hs:reason>
<hs:extendedMessage>No extended message available for this
error.</hs:extendedMessage>
<hs:result />
<hs:type />
</hs:rest>
Is not a way just to SEND THE login credentials? I find some OAUTH2
references to get "Authentiticated" but they get MORE AND MORE
confusing and has refernece to acess other services like Calendars or
other things like that and I had no clue, how to apply them in the
Reporting API