我正在用 PHP 编写一个应用程序,它将连接到我的域的 Google 课堂。但是,当我尝试使用 Google Classroom API 执行任何操作时,出现以下错误:
Message: Error calling GET https://www.googleapis.com/v1/courses?pageSize=100: (404) Not Found
到目前为止我的代码:
$scopes = array(
'https://www.googleapis.com/auth/classroom.courses',
'https://www.googleapis.com/auth/classroom.courses.readonly',
'https://www.googleapis.com/auth/classroom.rosters',
'https://www.googleapis.com/auth/classroom.rosters.readonly'
);
$gServiceEmail = "random@developer.gserviceaccount.com";
$gServiceKey = file_get_contents("../path/to/cert.p12");
$client = new Google_Client();
$gAuth = new Google_Auth_AssertionCredentials(
$gServiceEmail,
$scopes,
$gServiceKey
);
$gAuth->sub = "user@mydomain.com";
$client->setAssertionCredentials($gAuth);
$service = new Google_Service_Classroom($client);
$results = $service->courses->listCourses();
我已经在 Google 管理控制台的 API 设置中为服务帐户启用了范围,并在开发者控制台中启用了 api。我哪里错了?