0
我正在使用Google + HTTP API向people/get端点发出很多请求。事实证明这很慢,因为它需要为每个用户ID提供一个HTTP请求。
在文档中没有提到它,但是有什么方法可以在Google Plus API上发出批量请求吗?
或者,对于此用例的任何优化提示都非常受欢迎。Google Plus API上的批量请求
我正在使用Google + HTTP API向people/get端点发出很多请求。事实证明这很慢,因为它需要为每个用户ID提供一个HTTP请求。
在文档中没有提到它,但是有什么方法可以在Google Plus API上发出批量请求吗?
或者,对于此用例的任何优化提示都非常受欢迎。Google Plus API上的批量请求
我设法通过Google APIs Java client library在Google+ API上提出批量请求。
下面是一个代码示例:
BatchRequest batch = plus.batch();
Get me = plus.people().get("me");
Get angularJS = plus.people().get("110323587230527980117");
BatchCallback<Person, GoogleJsonErrorContainer> cb = new BatchCallback<Person, GoogleJsonErrorContainer>() {
@Override
public void onSuccess(Person person, HttpHeaders responseHeaders)
throws IOException {
System.out.println("batch success");
System.out.println(person.getDisplayName());
}
@Override
public void onFailure(GoogleJsonErrorContainer e, HttpHeaders responseHeaders)
throws IOException {
System.out.println("batch failure");
}
};
batch.queue(me.buildHttpRequest(), Person.class, GoogleJsonErrorContainer.class, cb);
batch.queue(angularJS.buildHttpRequest(), Person.class, GoogleJsonErrorContainer.class, cb);
batch.execute();
从谷歌显影剂导向https://developers.google.com/gdata/docs/batch – StarsSky
Google+尚未包括在谷歌数据API:https://开头developers.google.com/gdata/docs/directory – LoicAG
这是相同的批处理语义AFAIK。如果您使用的是Java客户端库,则批处理支持良好,与Python相同。 –