воскресенье, 6 ноября 2011 г.

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;

Комментариев нет:

Отправить комментарий