cfmgrv4/app/Controllers/Utils/RSSFeedController.php

27 lines
667 B
PHP

<?php
namespace App\Controllers\Utils;
use App\Controllers\CommonController;
class RSSFeedController extends CommonController
{
public function getITWorld()
{
$url = 'https://www.itworld.co.kr/rss/feed/index.php';
$rss = simplexml_load_file($url);
$items = [];
foreach ($rss->channel->item as $item) {
$items[] = [
'title' => (string) $item->title,
'link' => (string) $item->link,
'description' => (string) $item->description,
'pubDate' => (string) $item->pubDate
];
}
return $this->response->setJSON($items);
}
}