Skip to content

Instantly share code, notes, and snippets.

@supersupermomonga
Created September 29, 2015 00:16
Show Gist options
  • Save supersupermomonga/9dbdca0c361cd9219806 to your computer and use it in GitHub Desktop.
Save supersupermomonga/9dbdca0c361cd9219806 to your computer and use it in GitHub Desktop.
/*
* Feedly library for Google Apps Script
* @author Yoshiyuki Hirano <[email protected]>
*
*/
/* constructs an Feedly service
*
* @constructor
* @param {string} url
*
* @return {Feedly}
*/
function getInstance(url) {
return new Feedly(url);
}
/* constructs an Feedly service
*
* @constructor
* @param {string} url
* @throws {Object}
* @return {Feedly}
*/
function Feedly(url) {
var regexp = /^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/;
if (typeof url != 'string' || !regexp.test(url)) throw new Error('Invalid URL');
this.feedId = encodeURIComponent('feed/'+url);
}
/* get stats by feedId
*
* @return {Object}
*/
Feedly.prototype.getStats = function () {
var response = UrlFetchApp.fetch('http://cloud.feedly.com/v3/feeds/'+this.feedId);
return JSON.parse(response);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment