Skip to main content

How to Retrieve RSS Feeds with Kuroco?

It is possible to retrieve RSS feeds periodically using batch processing and add or update them in Kuroco's content.

Retrieving RSS Feeds

By writing the following Smarty code in batch processing, you can retrieve the contents of an RSS feed as an associative array.

{get_file var='rss_xml' url='https://www.diverta.co.jp/RSS.rdf' save=false}{* Retrieve the contents of the RSS feed *}
{xmltojson var='rss_json' xml=$rss_xml}{* Convert XML to JSON *}
{assign var='rss_feed' value=$rss_json|@json_decode}{* Convert JSON to an associative array *}
tip

You can confirm the retrieved and converted RSS content by adding the following code for testing:
test:{$rss_feed|@debug_print_var}

Updating Kuroco Content

If you want to update multiple contents at once, you can use the bulk_upsert API to reduce the number of requests and processing time. By converting the retrieved RSS data as shown below and posting it to the API, you can update the content.

{* Convert RSS data to the format of Kuroco content *}
{assign_array var='body' values=''}
{assign_array var='body.list' values=''}
{foreach from=$rss_feed.entry item='entry'}
{assign_array var='topics' values=''}
{assign var='topics.subject' value=$entry.title}
{assign var='topics.ext_1' value=$entry.id}
{assign var='topics.ext_2' value=$entry.updated}

{assign var='body.list.' value=$topics}
{/foreach}

{* Bulk update of content *}
{api_internal
var='response'
status_var='status'
endpoint='/rcms-api/1/topics/bulk_upsert'
method='POST'
queries=$body
member_id=1}

Support

If you have any other questions, please contact us or check out Our Slack Community.