是否有任何教程/示例解释了如何使用类ContentService方法创建rss feed?
答案 0 :(得分:6)
此示例从Gmail收件箱中创建RSS源(仅限每个线程中的第一条消息)。
<强> Code.gs 强>
function doGet() {
return ContentService.createTextOutput(HtmlService.createTemplateFromFile("rss").evaluate().getContent())
.setMimeType(ContentService.MimeType.RSS);
}
<强> rss.html 强>
<rss version="2.0">
<channel>
<title><?= "Gmail Feed" ?></title>
<? var threads = GmailApp.getInboxThreads();
var messages = GmailApp.getMessagesForThreads(threads);
for (var t in threads) { ?>
<item>
<title><?= threads[t].getFirstMessageSubject() ?></title>
<description><?= messages[t][0].getBody() ?></description>
<guid><?= threads[t].getId() ?></guid>
<pubDate><?= threads[t].getLastMessageDate().toUTCString() ?></pubDate>
</item>
<? } ?>
</channel>
</rss>
答案 1 :(得分:1)
点击此处:https://developers.google.com/apps-script/guides/content
function doGet() {
var feed = UrlFetchApp.fetch('http://xkcd.com/rss.xml').getContentText();
feed = feed.replace(
/(<img.*?alt="(.*?)".*?>)/g,
'$1' + new Array(10).join('<br />') + '$2');
return ContentService.createTextOutput(feed)
.setMimeType(ContentService.MimeType.RSS);
}