私はニュースアプリに取り組んでおり、から現在のニュースを解析する必要がありRSS (Really Simple Syndication)
ます。
フィードを簡単に解析できるSimplePieライブラリを見つけました。RSS
まず、このライブラリをサーバー上で直接使用しましたphp code
。
<?php
// Make sure SimplePie is included. You may need to change this to match the location of autoloader.php
// For 1.0-1.2:
#require_once('../simplepie.inc');
// For 1.3+:
require_once('./php/autoloader.php');
// We'll process this feed with all of the default options.
$feed = new SimplePie("https://news.google.com/news/feeds?pz=1&cf=all&ned=us&hl=en&topic=h&num=3&output=rss");
// Set which feed to process.
// Run SimplePie.
$feed->init();
// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();
foreach ($feed->get_items() as $item):
?>
<div class="item">
<h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
<p><?php echo $item->get_description(); ?></p>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
</div>
<?php
endforeach;
?>
しかし、私は自分の PC でこのファイルを実行しています。次のエラーが発生しました。
Deprecated: Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly. in C:\xampp\htdocs\apps\liveibl\php\library\SimplePie.php on line 640
これはPHPのバージョンが原因で発生したと思いますが、どうすればよいかわかりません。
助けてください...
前もって感謝します。