gpt4 book ai didi

node.js - 429 - {"status":"error","message":"Api max rps reached"} 向manychat sendFlow API发送请求时

转载 作者:太空宇宙 更新时间:2023-11-03 22:56:51 24 4
gpt4 key购买 nike

我正在尝试使用其 API 将 CustomField 设置为 Manychat 订阅者。他们的 API 链接是:

https://api.manychat.com/swagger#/Subscriber/post_fb_subscriber_setCustomFieldByName

以下是请求代码:

   var rp = require("request-promise");
var config = require("./../campaign_config.json");

module.exports = { setWaybillForUser : async function setWaybillForUser(userid,waybill,dbRef){

var options = { method: 'POST',
uri: 'https://api.manychat.com/fb/subscriber/setCustomFieldByName',
headers:
{'Cache-Control': 'no-cache',
Accept: '*/*',
Authorization: config.Manychat_token,
'Content-Type': 'application/json' },
body:
{ subscriber_id: parseInt(userid),
field_name: 'waybill',
field_value: waybill },
json: true };

try {
const response = await rp(options);
console.log(response);
if (response.status == "success") {
return dbRef.child('datanode').child(userid).update({
"Order_Status": 3
}).then(function () {
//do nothing.
}).catch(function (error) {
console.log(error);
});
}
}
catch (err) {
console.log(err.message);
}
}
};

我多次调用此函数,因为必须为许多订阅者运行该函数。调用它的代码是:

dbRef.child("subData").once('value').then(function(snapshot){
var data = snapshot.val();
var keys = Object.keys(data);

let promiseArray = [];
let orderStatusArr =[];
for(let i=0; i< keys.length; i++){

var order_status = data[keys[i]].Order_Status;
var subid = data[keys[i]].UserID;
var waybill = data[keys[i]].Waybill_Number;
if(order_status == 1){
orderStatusArr.push({
"Order_Status":order_status,
"UserID": subid,
"Waybill_Number":waybill
});
}
}

for(let i=0; i<orderStatusArr.length;i++){
var order_status = orderStatusArr[i].Order_Status;
var subid = orderStatusArr[i].UserID;
var waybill = orderStatusArr[i].Waybill_Number;

promiseArray.push(setWaybillsForUser.setWaybillForUser(subid,waybill,dbRef));
}

Promise.all(promiseArray).then(() => {
// all done here
response.send("success");
}).catch(function(err) {
console.log(err.message);
});

})

当我运行代码时 - 它会记录某些请求的成功,同时为其他请求抛出上述内容。它一次能够成功为大约 10 个订阅者运行代码。

最佳答案

来自this page :

Is there any limit to a number of API calls?

There is only a request per second limit for POST methods (per page):

  1. /fb/sending/sendFlow, /fb/sending/sendContent - 25 RPS;
  2. /fb/subscriber/addTag, /fb/subscriber/removeTag, /fb/subscriber/setCustomField - 10 RPS.

因此,从这一点以及您发布的症状来看,似乎第二条规则适用

关于node.js - 429 - {"status":"error","message":"Api max rps reached"} 向manychat sendFlow API发送请求时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59674706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com