-1

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] 的值

4

1 回答 1

0

下面的链接非常有帮助,我在服务帐户和 Oauth2.0 上都成功了,这解决了我的目的。

适合初学者的一款

http://www.daimto.com/google_service_account_php/

http://www.daimto.com/google-oauth2-php/

于 2016-02-03T01:31:10.597 回答