- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2017 11:42 AM
Hi Guys,
I want to be able to put an RSS feed on my Service Portal. Has anyone been successful in creating one and helping me out in creating one? Ideally, I want to pull the feed from Krebs at the top of the service portal homepage.
Thanks,
David R
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2017 06:59 AM
Hi David,
The reason the code you supplied doesn't work in Service Portal is because it uses an iframe that has a src path using plain http instead of https. It looks like you got the code from rssfeedwidget.com. But I don't believe they use https. So, even changing the url in the src attribute to use https more than likely won't get that to work either.
An alternative could be to use the RestMessageV2 and XMLDocument2 methods (and of course html and css to style it the way you want) to bring in the feed to your widget I have put together a very basic poc. It will bring in the Krebs on Security feed. It could also handle others too with a little adjustment. Most rss feeds are pretty much standard containing elements like channel, title, items, links etc.
Try putting this code within a widget and placing the widget on a page:
HTML:
<div class="panel panel-primary" ng-repeat="feed in c.data.feeds">
<div class="panel-heading">
<h4>${{{ feed.channel.title }}} - {{ feed.channel.description }}</h4>
</div>
<div>
<div class="list-group">
<div ng-repeat="item in feed.channel.items | limitTo: (offset - feed.channel.items.length) as filtered" class="list-group-item">
<a ng-href="{{item.link}}" target="_blank"><h3>{{ item.title }}</h3></a>
<h5>Author: {{ item['dc:creator'] }}</h5>
<div class="item-content">{{ item.description }}</div>
</div>
</div>
</div>
</div>
-------------------------------
CSS:
.item-content img {
width: 30%;
height: 30%;
display: block;
}
.feed-btn:first-of-type {
margin-left: 5px;
}
.feed-btn {
font-size: 9px;
}
----------------------
Server Script:
(function() {
try {
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('GET');
r.setEndpoint('https://krebsonsecurity.com/feed/');
var response = r.execute();
var responseBody = response.getBody();
data.httpStatus = response.getStatusCode();
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(responseBody);
data.feeds = [];
var feed = {};
feed.channel = {};
var channel = xmlDoc.getNode('//channel');
var channelIter = channel.getChildNodeIterator();
var items = [];
while(channelIter.hasNext()){
var node = channelIter.next();
var nodeName = node.getNodeName();
var nodeContent = node.getTextContent();
if(nodeName != '#text' && nodeName != 'item')
feed.channel[nodeName] = nodeContent;
if(nodeName == 'item'){
var item = {};
var category = '';
var itemIter = node.getChildNodeIterator();
while(itemIter.hasNext()){
var itemNode = itemIter.next();
var itemName = itemNode.getNodeName();
var itemContent = itemNode.getTextContent();
if(itemName != '#text' && itemName != 'category')
item[itemName] = itemContent;
if(itemName == 'category'){
if(category.length > 0)
category += ','+itemContent;
else
category += itemContent;
}
}
item.categories = category.split(",");
items.push(item)
}
feed.channel.items = items;
}
data.feeds.push(feed);
}
catch(ex) {
var message = ex.getMessage();
}
})();
This should give you a good starting point.
I hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2018 11:52 PM
Wow, you're awesome, thanks for this! Actually we were in my case able to fix the sorting already from the source data point of view, so after all this 're-sorting' was no-longer needed, I sure hope that this will help somebody else with similar issues when no options to fix the source sorting.
Great help, thank you a lot!
BR,
Paavo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 09:50 AM
The gift that keeps on giving. Worked like a charm Chris, and was able to easily adapt it to a different RSS feed with minimal fuss.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 06:56 AM
Hi everyone,
The code above works perfectly but I don't understand how it works if we wanna change the rss feed, from another website.
I don't know how to script and even though I tried to understand how to change, I don't understand.
Thanks for your help
Juliette
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2021 07:56 AM
Hi Juliette,
Yeah, this script was pretty much built specifically for the Krebs on Security feed as well as only being a POC to give an example of how it could be done. So, there aren't any real options built-in.
However, it still can be leveraged. To point to a different feed you would change the script where it defines the endpoint with the url of the RSS feed you desire.
r.setEndpoint('https://change to the desire path');
If your desired RSS feed has a different xml structure you would then need to analyze that structure and modify the script to pull the necessary data into the html markup.