Google Classroom quickstart.php 非常适合我。
现在我需要创建提示用户登录(Oauth)的网页,并使用这些凭据列出他们的课程。
我在 Google Classroom 问题中尝试了该示例,但都以 Google 错误告终。
任何工作样本将不胜感激。
提前致谢。
1)首先让我知道下面的例子是否正确
<?php
require __DIR__ . '/src/Google/autoload.php';
/*TODO: get stored $credentials */
$client = new Google_Client();
$client->setClientId('myServiceAccountClientID');
$client->setRedirectUri('REDIRECTURI_PAGE');
$client->setClientSecret('SECRETKEY');
$client->setScopes(array('https://www.googleapis.com/auth/classroom.courses','https://www.googleapis.com/auth/classroom.courses.readonly'));
$client->setAccessToken($credentials);
$service = new Google_Service_Classroom($client);
$results = $service->courses->listCourses();
?>
$credentials 是我通过运行 Quickstart.php 获得的 $GET[code] 的值