Google Chat API 获取空间消息列表
我正在尝试让这个例子在Python中运行。
def get_msg():
creds = None
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', ['https://www.googleapis.com/auth/chat.spaces', 'https://www.googleapis.com/auth/chat.messages')
chat = build('chat', 'v1', credentials=creds)
result = chat.spaces().messages().list(name='spaces/123456789').execute()
print(result)
def main():
get_msg()
出现了这个错误:
Traceback (most recent call last):
File "C:\30_py\google\chat\test_chat.py", line 64, in <module>
main()
File "C:\30_py\google\chat\test_chat.py", line 57, in main
get_msg()
File "C:\30_py\google\chat\test_chat.py", line 46, in get_msg
result = chat.spaces().messages().list(name='spaces/123456789').execute()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Resource' object has no attribute 'list'
我在API探索工具中测试了授权和空间名称,结果是可以的。我用不同的接口成功获取了空间列表,所以我的凭证、令牌和逻辑都是有效的。不过,我在尝试让这个接口正常工作时遇到了麻烦,也就是想解决这个属性错误。任何想法和建议都非常欢迎。