【发布时间】:2020-05-30 16:21:36
【问题描述】:
我在使用任何未在某处明确举例说明的客户端服务方法时都遇到困难。尽管遵循了文档,甚至阅读了源代码,但我提出的遵循方案的类或方法名永远不会正确。
Packagist 的文档(请参阅“发出请求”)说客户端库类是从 Google 端点自动生成的,这与 library's docs on Github 中的描述一致,即访问方法的模式应该是“@987654324 @"。
那么为什么会出现以下情况?
// works:
// I get a countable object of active classrooms owner by the specified id
$response = $this->ClassroomService->courses->listCourses([
'courseStates' => 'ACTIVE',
'teacherId' => 'me']);
// works:
// I get an instance of the single classroom's object containing lots of meta data
$response = $this->ClassroomService->courses->get( $id );
// does not work:
// 500 error, obj has no such method
$response = $this->ClassroomService->topics->listCoursesTopics( $id );
根据API Explorer,这三个都应该没问题。
我在使用客户端服务对象时缺少什么?
编辑
最终,我将示例中的资源确定为“courses_topics”;根据文档,该方法是正确的。感谢@ebram 的想法。
问题仍然是这些方法是如何命名的。 courseWork 是我的下一个挑战,它不符合 topics 的命名模式。
【问题讨论】:
-
也许尝试 var_dump 主题? :P 这就是我真正陷入困境时所做的事情
标签: php google-api google-api-php-client google-classroom