Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The Google Spreadsheets Script Used To Call Social Media APIs
function FBshares(url) {
var jsondata = UrlFetchApp.fetch("http://graph.facebook.com/"+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.shares;
}
function Tweets(url) {
var jsondata = UrlFetchApp.fetch("http://urls.api.twitter.com/1/urls/count.json?url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.count;
}
function Linkedin(url) {
var jsondata = UrlFetchApp.fetch("http://www.linkedin.com/cws/share-count?url="+url);
return jsondata.getContentText();
}
function SU(url) {
var jsondata = UrlFetchApp.fetch("http://www.stumbleupon.com/services/1.01/badge.getinfo?url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.result.views;
}
function Gbuzz(url) {
var jsondata = UrlFetchApp.fetch("https://www.googleapis.com/buzz/v1/activities/count?alt=json&url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return jsondata.getContentText();
}
function delicious(url) {
var jsondata = UrlFetchApp.fetch("http://feeds.delicious.com/v2/json/urlinfo/data?url="+url);
return jsondata.getContentText();
}
function reddit(url) {
var jsondata = UrlFetchApp.fetch("http://www.reddit.com/api/info.json?url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
var count = 0;
var forloop = 0;
for (var i in object.data.children) {
count = count + object.data.children[forloop].data.score;
forloop = forloop + 1;
}
return count;
}
@michaelkparker

This comment has been minimized.

Copy link

michaelkparker commented May 12, 2016

How do you use this in Google Sheets? E.g. Once you install the code, how would you use it in a cell?

@ramanadan36

This comment has been minimized.

Copy link

ramanadan36 commented Jan 26, 2019

Could you please document little more about what this script would do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.