2016-11-19 5 views
1

Ich versuche, diesen CodeGoogle api Analytik: error listManagementAccounts in HelloAnalytics.php

<?php 


error_reporting(E_ALL); 
ini_set("display_errors", 1); 
// Load the Google API PHP Client Library. 
require_once __DIR__ . '/vendor/autoload.php'; 

$analytics = initializeAnalytics(); 



$profile = getFirstProfileId($analytics); 
/*$results = getResults($analytics, $profile); 
printResults($results);*/ 

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__ . '/service-account-credentials.json'; 

    // Create and configure a new client object. 
    $client = new Google_Client(); 
    $client->setApplicationName("Hello Analytics Reporting"); 
    $client->setAuthConfig($KEY_FILE_LOCATION); 
    $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']); 
    $analytics = new Google_Service_Analytics($client); 

    return $analytics; 
} 

function getFirstProfileId($analytics) 
{ 
    // Get the user's first view (profile) ID. 

    // Get the list of accounts for the authorized user. 

    $accounts = $analytics->management_accounts->listManagementAccounts(); 
..... 

Aber ich diesen Fehler zu verwenden:

Catchable fatal error: Argument 2 passed to Google\Auth\CredentialsLoader::makeCredentials() must be of the type array, object given, called in /home/julienlakq/new_site/administration/analytics/src/Google/Client.php on line 1052 and defined in /home/julienlakq/new_site/administration/analytics/vendor/google/auth/src/CredentialsLoader.php on line 115

ich alle Schritte befolgt haben: erstellt eine jey , erstellt via google ein json Schlüssel

https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-php#3_setup_the_sample

Ist jemand dieses p hatte Problem?

Vielen Dank!

Antwort

0

Problem gelöst.

Erstens: Wurde für v3 mit v4 api verwendet Beispiel: es

Zweitens: weg Form PHP 5.6 7

PHP und dann ist alles in Ordnung ;-)

Verwandte Themen