-
-
Save vilbht/47234c47fd7deb1691ba to your computer and use it in GitHub Desktop.
The Google Spreadsheets Script Used To Call Social Media APIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment