-
-
Save efremfilho/866585d063c9679692414083eaff4d02 to your computer and use it in GitHub Desktop.
Google Spreadsheet to RSS ATOM - Google Apps Script
This file contains 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 doGet(e) { | |
var rss='<?xml version="1.0" encoding="utf-8"?>'; | |
rss+='<feed xmlns="http://www.w3.org/2005/Atom">'; | |
rss+='<title>Frases y citas célebres - NexCono </title>'; | |
rss+='<link href="http://nexcono.appspot.com"/>'; | |
rss+='<author><name>NexCono</name></author>'; | |
rss+='<id></id>'; | |
var app=SpreadsheetApp.openById("1tLSL5BqnTAM6VsgyF355DJJe50r0ZQbfunTXAUFj_nE"); | |
var data=app.getDataRange().getValues(); | |
var lastTime; | |
for(var i=1;i<data.length;i++){ | |
var date=new Date(data[i][0]); | |
//Logger.log("DATE: "+date.toISOString()); | |
//Logger.log("AUTOR: "+data[i][2]); | |
rss+='<entry>'; | |
rss+='<title>Frase de '+data[i][2]+'</title>'; | |
rss+='<content>«'+data[i][1]+'» - '+data[i][2]+'</content>'; | |
rss+='<summary>«'+data[i][1]+'» - '+data[i][2]+'</summary>'; | |
rss+='<link rel="alternate" href="http://nexcono.appspot.com"/>'; | |
rss+='<id>http://nexcono.appspot.com/frase/'+date.toISOString()+'</id>'; | |
rss+='<updated>'+date.toISOString()+'</updated>'; | |
rss+='</entry>'; | |
lastTime=date.toISOString(); | |
} | |
rss+='<updated>'+lastTime+'</updated>'; | |
rss+='</feed>'; | |
return ContentService.createTextOutput(rss).setMimeType(ContentService.MimeType.ATOM); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment