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 *}
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
When updating multiple pieces of content in bulk, you can reduce the number of requests and processing time by using the bulk_upsert API. Please use it as needed.
Additionally, if you specify in the request body’s topics_id field the item name set in the id_reference_allow_list parameter, you can add or update content using any desired item as the key instead of topics_id.
For example, in the case below, if content with the same ext_1 exists, it will be updated.
{* 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.topics_id' value='ext_1'}
{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}
Related Documents
Support
If you have any other questions, please contact us or check out Our Slack Community.