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')