2
我正在用PHP編寫一個應用程序,它將連接到我的域的Google課堂。不過,我得到以下錯誤,當我嘗試用谷歌課堂API做任何事情:使用Google Classroom API時,爲什麼會出現404錯誤?
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 = "[email protected]";
$gServiceKey = file_get_contents("../path/to/cert.p12");
$client = new Google_Client();
$gAuth = new Google_Auth_AssertionCredentials(
$gServiceEmail,
$scopes,
$gServiceKey
);
$gAuth->sub = "[email protected]";
$client->setAssertionCredentials($gAuth);
$service = new Google_Service_Classroom($client);
$results = $service->courses->listCourses();
我已啓用的API設置的範圍在谷歌管理員服務帳戶的控制檯並在開發者控制檯中啓用了api。我哪裏錯了?
我有一個老版本的PHP客戶端LIB的。升級到最新版本解決了問題,因爲它在您的答案中使用了正確的端點 – amburnside