【发布时间】:2018-06-14 14:49:18
【问题描述】:
我正在使用 google Classroom google API 和用于 PHP 的 Google APIs 客户端库。
我可以添加公告,但我不能添加材料。
我想将文件添加到 Google 云端硬盘,但即使使用“链接”也有错误
到目前为止我的代码:
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setApplicationName("test classroom");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/classroom.courses',
"https://www.googleapis.com/auth/classroom.rosters",
"https://www.googleapis.com/auth/classroom.announcements",
"https://www.googleapis.com/auth/classroom.coursework.students",
"https://www.googleapis.com/auth/classroom.coursework.me",
]);
// $service implements the client interface, has to be set before auth call
$service = new Google_Service_Classroom($client);
$text="some text";
$link="http://someurl";
$glink = new Google_Service_Classroom_Link($link);
$glink->setUrl($link);
$params = [
"text" => $text,
"materials" => [
"link" => $glink,
],
];
$params_obj = new Google_Service_Classroom_Announcement($params);
$service->courses_announcements->create($course_classid, $params_obj);
//tried also with:
$params = [
"text" => $text,
"materials" => [
"link" => ((new Google_Service_Classroom_Material())->setLink($glink)) ,
],
];
错误:
"message": "materials: Link materials must have a URL.",
【问题讨论】:
标签: php google-api-php-client google-classroom