Youtube api YouTube分析API+;服务访问=致命错误:未捕获异常(500)

Youtube api YouTube分析API+;服务访问=致命错误:未捕获异常(500),youtube-api,google-api,google-oauth,google-api-php-client,youtube-analytics,Youtube Api,Google Api,Google Oauth,Google Api Php Client,Youtube Analytics,为了执行一些CRON任务,我正在尝试使用带有服务帐户的API获取一些YouTube分析报告。我已经解决了NTP服务器同步的常见问题,显然,我已经正确设置了API控制台 <?php ini_set('display_errors', 1); require_once 'gapi/src/Google_Client.php'; require_once 'gapi/src/contrib/Google_YouTubeAnalyticsService.php'; // Define

为了执行一些CRON任务,我正在尝试使用带有服务帐户的API获取一些YouTube分析报告。我已经解决了NTP服务器同步的常见问题,显然,我已经正确设置了API控制台

    <?php

ini_set('display_errors', 1);

require_once 'gapi/src/Google_Client.php';
require_once 'gapi/src/contrib/Google_YouTubeAnalyticsService.php';

// Define constants.
const CLIENT_ID = '************************.apps.googleusercontent.com';
const SERVICE_ACCOUNT_NAME = '************************@developer.gserviceaccount.com';
const KEY_FILE = '************************-privatekey.p12';
const MY_CHANNEL = '************************';


$client = new Google_Client();
$client->setApplicationName("YouTube Analytics API Test");

session_start();
if (isset($_SESSION['token'])) {
 $client->setAccessToken($_SESSION['token']);
}

$key = file_get_contents(KEY_FILE);
$client->setAssertionCredentials(new Google_AssertionCredentials(
    SERVICE_ACCOUNT_NAME,
    array("https://www.googleapis.com/auth/yt-analytics.readonly"),
    $key)
);

$client->setClientId(CLIENT_ID);

if ($client->getAuth()->isAccessTokenExpired()) {
  $client->getAuth()->refreshTokenWithAssertion();
}

$token = $client->getAccessToken();

$youtubeAnalyticsService = new Google_YouTubeAnalyticsService($client);

$optparam = array("dimensions" => "country", "max-results" => "10");
$reports = $youtubeAnalyticsService->reports->query("channel==" . MY_CHANNEL, "2013-09-01", "2013-09-25", "views", $optparam);

echo $reports;
?>

有什么建议吗?提前谢谢大家

我正在调查这个问题:你是否找到任何解决方案?如果是,请告诉我。谢谢
Fatal error: Uncaught exception 'Google_ServiceException' with message


'Error calling GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DmychannelID&start-date=2013-09-01&end-date=2013-09-25&metrics=views&dimensions=country&max-results=10: (500) Unknown error occurred on the server.' in /mydomain/gapi/src/io/Google_REST.php:66

Stack trace:
0 /mydomain/gapi/src/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest))  
1 /mydomain/gapi/src/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest))
2 /mydomain/gapi/src/contrib/Google_YouTubeAnalyticsService.php(48): Google_ServiceResource->__call('query', Array)
3 /mydomain/myfile.php(45): Google_ReportsServiceResource->query('channel==...', '2013-09-01', '2013-09-25', 'views', Array)

4 {main} thrown in /mydomain/gapi/src/io/Google_REST.php on line 66