27 lines
651 B
PHP
27 lines
651 B
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\Controller;
|
|
|
|
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);
|
|
}
|
|
}
|