0

一些较旧的 Google API(如联系人)允许您进行批量调用。这可以通过 Python Drive API 实现吗?

具体来说,我想知道是否可以在一次 API 调用中获取多个文件的评论。

4

1 回答 1

3

挖掘文档后的一个简单示例,假设您将凭据存储在变量 creds 中:

def list_animals(request_id, response, exception):
    if exception is not None:
        # Do something with the exception.
        pass
    else:
        # Do something with the response.
        pass

def list_farmers(request_id, response, exception):
    if exception is not None:
        # Do something with the exception.
        pass
    else:
        # Do something with the response.
        pass

service_ = authHandler.CreateService('drive', 'v2', creds)

batch = BatchHttpRequest()

batch.add(service_.changes().list(), list_animals)
batch.add(service_.changes().list(), list_farmers)
batch.execute(http=authHandler.getHttp(creds))
于 2013-02-21T14:16:04.723 回答