Facebook的图形API错误网址提取失败,因为太多的流量被发送到指定的URL(Facebook

2019-10-29 04:39发布

我试图获取使用Facebook的图形API从谷歌Facebook的脚本广告Campaings。

我有差不多5500的数据,我想取每10分钟的数据,并在电子表格中添加更新的数据。

该代码是工作的罚款。 但经过2-3次迭代,我得到一个错误

UrlFetch failed because too much traffic is being sent to the specified URL

如果我分享我的其他电子邮件再次它的工作对未来2-3个迭代谷歌脚本,然后再次失败。

我有一个解决方案时的加一个额外的选项的获取从数据上的问题#1

但添加选项后

{"useIntranet" : true}

我收到请求超时问题。

是否有任何其他的解决方案来解决这个问题? 我需要在一整天中取每10分钟的数据。

Answer 1:

这是不是与你的电话,但你正在呼叫的数量问题。 您可能需要降低一点。 正如你可以看到这里 ,极限是使每600秒(10分钟),600电话。 所以,这取决于你取什么,如何及在何种虽然,我觉得多少数量的描述,就足以使我确信你能够做出2-3次迭代的原因是因为由第三一个结束你已经超过了1个呼叫/秒的速率,它基本上是关闭掉你从那里。

我也建议你来看看这个页面的有关Facebook的图形API一些限速信息。



Answer 2:

与代码更参加工作后,我得到了什么,虽然有像每600秒(10分钟),600呼叫FB图形API的限制。 但是从谷歌调用FB图形API的限制Apps Script是相当少它。 这就是为什么当我加载在每次10分钟使用jQuery的Ajax的数据它工作正常,但是当我加载相同的数据使用

UrlFetchApp.fetch

在谷歌Apps脚本它阻止我后每天2-3尝试。

所以,当限制在FB图形API从谷歌Apps脚本,我试图调用一些其他的API,而不是FB图形API和它的工作,它没有阻止我。

所以,我创建了一个节点JS服务器,如: -

var express = require("express"),
app = express(),
cors = require('cors'),
bodyParser = require('body-parser'),
request = require('request');
app.use(cors());

app.use( bodyParser.json() );       // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({     // to support URL-encoded bodies
  extended: true
})); 

app.get("/test",function(req,res){
  res.send("Test success");
})
app.post('/getFbFeed', function(req, res) {
  // Sending request to fb api using the request modules of node, the fb  feed url is coming from
  // the frontend as a request parameter.
   request(req.body.url, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        res.send(body); // Send the response of the requested url to the frontend.
      }
  })
})
app.listen(process.env.PORT || 3000);

所以这个代码将加载从FB图形API的数据,我会将网址为FB图形API从谷歌的Apps脚本。

所以,在谷歌的Google Apps脚本,我写

var options =
  {
   "method" : "post",
   "payload" : {"url" : url}
  };
 // Sending post request to node js server with the fb feed url to load data as there is limit to load data from fb to google apps script.
  response = UrlFetchApp.fetch("http://fbfeed-48431.onmodulus.net/getFbFeed",options);


文章来源: Facebook graph api error UrlFetch failed because too much traffic is being sent to the specified URL