UrlFetch失败,因为太多的流量正在发送到指定的URL [英] UrlFetch failed because too much traffic is being sent to the specified URL

查看:254
本文介绍了UrlFetch失败,因为太多的流量正在发送到指定的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Google表格编写一个脚本,它使用Facebook的Graph API来获取我的数据。一切工作在今天早些时候,但突然我得到一个错误:


UrlFetch失败,因为太多的流量正在发送到
指定的URL。

我没有使用UrlFetch的任何配额,因为我仍然可以从其他非graph.facebook .com - 所以这个问题似乎是专门针对Facebook的。



脚本代码



< pre class =lang-js prettyprint-override> var myClientID ='';
var myClientSecret ='';
var myAccessToken ='';
var graphURL ='https://graph.facebook.com/v2.3/';

function getPageLikes(campaign_id){
var searchParams ='/ stats?fields = actions';
var campaignID = campaign_id;
var fullURL = graphURL + campaignID + searchParams +'& access_token ='+ myAccessToken;
var fetchResult = UrlFetchApp.fetch(fullURL);
var campaign = JSON.parse(fetchResult);
var likes = campaign.data [0] .actions.like;
返回喜欢;
}

Google表单公式

  = getWebClicks('E2')


解决方案

经过多一点研究后,我发现了一个解决方案。我添加了'useIntranet'选项作为fetchResult的参数,并且似乎解决了这个问题。我想这个请求现在是从另一个不会限制请求到Facebook的Graph API的资源发送的。



如果有人能解释为什么这个解决了我的问题,那会是

  var options = {useIntranet:true}; 
var fetchResult = UrlFetchApp.fetch(fullURL,options);


I'm writing a script for Google Sheets that uses Facebook's Graph API to get my data. Everything worked earlier today but suddenly I'm getting an error:

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

I haven't hit any quotas about using UrlFetch because I can still fetch from other urls that are not graph.facebook.com - so the issue appears to be specifically with Facebook.

Script Code

var myClientID = '';
var myClientSecret = '';
var myAccessToken = '';
var graphURL = 'https://graph.facebook.com/v2.3/';

function getPageLikes(campaign_id) {
  var searchParams = '/stats?fields=actions';
  var campaignID = campaign_id;
  var fullURL = graphURL + campaignID + searchParams + '&access_token=' + myAccessToken;
  var fetchResult = UrlFetchApp.fetch(fullURL);
  var campaign = JSON.parse(fetchResult);
  var likes = campaign.data[0].actions.like;
  return likes;
}

Google Sheet Formula

=getWebClicks('E2')

解决方案

I discovered a solution after a little more research. I added the 'useIntranet' option as a parameter to fetchResult and that seemed to solve the issue. I imagine the request is now being sent from another resource that doesn't limit requests to Facebook's Graph API.

If anyone can explain why this fixed my problem, that would be great as well!

var options = {"useIntranet" : true};
var fetchResult = UrlFetchApp.fetch(fullURL, options);

这篇关于UrlFetch失败,因为太多的流量正在发送到指定的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆