【发布时间】:2021-08-17 01:23:46
【问题描述】:
我正在尝试将使用 Google Classroom API 创建的仪表板中的草稿成绩更新到某个项目的 Google 课堂本身。我写了以下代码,但找不到出路。如何解决这个问题?
附上仪表板(从 Google 课堂导入的所有值)供您参考。
$client = new Google_Client();
$service = new \Google_Service_Classroom($client);
$courseId = '328776504166';
$courseWorkId = '361223650991';
$id = 'Cg0IiOu99CkQr_3t1MEK';
$post_body = new \Google_Service_Classroom_StudentSubmission(array(
'updateMask' => 20,
'draftGrade' => 90,
));
$list = $service->courses_courseWork_studentSubmissions->patch($courseId, $courseWorkId, $id, $post_body,);
然后当我在 localhost 上运行上面的代码时,我看到了这个问题:
PHP Fatal error: Uncaught Google\Service\Exception: {
"error": {
"code": 403,
"message": "@ProjectPermissionDenied The Developer Console project is not permitted to make this request.",
"errors": [
{
"message": "@ProjectPermissionDenied The Developer Console project is not permitted to make this request.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
【问题讨论】:
-
您当前的解决方案有什么问题,您有错误吗?
-
@DaImTo 是的,我发现有问题。我已经更新了我的问题。当我想更新草稿成绩时出现上述问题。
-
@DaImTo 我必须从我的项目中创建课程、课程作业(作业)。非常感谢您提出宝贵的建议。现在这个问题已经完全解决了。
标签: php oauth google-api-php-client google-api-client google-classroom