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相同。 –