一种仅在 google 个教室 API python 上使用非存档教室的方法
A way to only use non archived classrooms on google classrooms API python
现在我编写的脚本可以显示我注册过的所有课程。
courselist = []
results = service.courses().list(pageSize=100).execute()
courses = results.get('courses', [])
courses
将 return 我注册过的每一门课程。我想知道是否有办法只获取我目前注册的教室,同时排除存档的教室。
我试过更改 pageSize,但这只会更改存储的课程数量。
您可以使用 courseState 请求参数,这将允许您根据课程的状态选择要检索的课程。这就是使用 Python:
的方式
# Call the Classroom API
results = service.courses().list(
pageSize=10,
# List with the course's states
courseStates= ["ACTIVE"] # Another Ex: ["ACTIVE", "ARCHIVED"]
).execute()
courses = results.get('courses', [])
if not courses:
print('No courses found.')
else:
print('Courses:')
for course in courses:
print(course['name'] + ": " + course['courseState'])
您也可以使用 Try this API.
在 API 端点直接测试它
现在我编写的脚本可以显示我注册过的所有课程。
courselist = []
results = service.courses().list(pageSize=100).execute()
courses = results.get('courses', [])
courses
将 return 我注册过的每一门课程。我想知道是否有办法只获取我目前注册的教室,同时排除存档的教室。
我试过更改 pageSize,但这只会更改存储的课程数量。
您可以使用 courseState 请求参数,这将允许您根据课程的状态选择要检索的课程。这就是使用 Python:
的方式# Call the Classroom API
results = service.courses().list(
pageSize=10,
# List with the course's states
courseStates= ["ACTIVE"] # Another Ex: ["ACTIVE", "ARCHIVED"]
).execute()
courses = results.get('courses', [])
if not courses:
print('No courses found.')
else:
print('Courses:')
for course in courses:
print(course['name'] + ": " + course['courseState'])
您也可以使用 Try this API.
在 API 端点直接测试它