我想检索用户联系人的电子邮件地址。我打算使用 Google People API。这是我要检索的功能:
function makeApiCall() {
gapi.client.load('people', 'v1').then(function() {
var request = gapi.client.people.people.connections.list({
resourceName: 'people/me',
pageSize: 200,
fields: 'connections(resourceName)'
});
request.execute(function(resp) {
if (resp.connections){
var batch = gapi.client.newBatch();
var emails = [];
for(var i = 0; i < resp.connections.length; i++){
var req = gapi.client.people.people.get({
resourceName: resp.connections[i].resourceName,
fields: "emailAddresses(value)"
});
batch.add(req);
req.then(function (email){
var idx = email.body.indexOf("{");
var jsonString = email.body.substring(idx > 0 ? idx : 0);
var obj;
try {
obj = JSON.parse(jsonString);
if (obj.emailAddresses){
for (j = 0; j < obj.emailAddresses.length; j++){
emails.push(obj.emailAddresses[j].value);
}
}
} catch (err) {
console.error(email);
}
})
}
batch.then(function (){
console.log(emails);
}, function (err){
console.error(err);
});
} else {
console.error("Error", resp);
}
});
}, function (err){
console.error(err);
});
}
基本上,我要获取 200 个连接来检索它们的资源名称。
此 reresourceName 将用于获取用户的电子邮件地址。
我正在使用批处理请求来获取 200 个用户的电子邮件。
问题是,对于某些用户,我收到以下错误:
{
"error": {
"code": 429,
"message": "Insufficient tokens for quota group and limit ReadGroupUSER-100s using the limit by ID 991457241470@515501272068.",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/991457241470/apiui/credential"
}
]
}
]
}
}
可能是什么原因,我该如何解决这个问题?
谢谢