po wklejeniu:
error_reporting(E_ALL);
ini_set('display_errors','1');
na początku strony pokazuje:
"Fatal error: Uncaught exception 'Google_Exception' with message 'Invalid client secret JSON file.' in /[...]/google-api-php-client/src/Google/Client.php:171 Stack trace: #0 /[...]/view/admin/HelloAnalytics.php(47): Google_Client->setAuthConfig('/home/admin/web...') #1 /[...]/view/admin/HelloAnalytics.php(30): initializeAnalytics() #2 {main} thrown in /[...]/google-api-php-client/src/Google/Client.php on line 171"
Ponieważ nie mogę ujawnić strony pod [...] kryje się link do głównego folderu.
view\admin\HelloAnalytics.php
[30] $analytics = initializeAnalytics();
[35-52]
function initializeAnalytics()
{
// Creates and returns the Analytics Reporting service object.
// Use the developers console and download your service account
// credentials in JSON format. Place them in this directory or
// change the key file location if necessary.
$KEY_FILE_LOCATION = __DIR__ . 'view\admin\client_secret.json';
// Create and configure a new client object.
$client = new Google_Client();
$client->setApplicationName("Hello Analytics Reporting");
$client->setAuthConfig($KEY_FILE_LOCATION); // <- [47]
$client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
$analytics = new Google_Service_Analytics($client);
return $analytics;
}
google-api-php-client\src\Google\Client.php
[166-178]
public function setAuthConfig($json)
{
$data = json_decode($json);
$key = isset($data->installed) ?
'installed' : 'web'; if (!isset($data->$key)) { throw new Google_Exception("Invalid client secret JSON file.");
}
$this->setClientId($data->$key->client_id);
$this->setClientSecret($data->$key->client_secret);
if (isset($data->$key->redirect_uris)) { $this->setRedirectUri($data->$key->redirect_uris[0]);
}
}
nawet po ponownym pobraniu pliku (niby właściwego dla utworzonego projektu w "console.developers.google.com/apis/credentials") nie działa