[eluser]Unknown[/eluser]
hi guy,
I junior in code igniter, what I want to do is what is this error and how to fixed my error, I copy the rsspraser on this link
http://ellislab.com/forums/viewthread/160394/
here is my code:
controller file
Code:
<?php
class Feed extends CI_Controller{
function index()
{
$this->load->librarier('RSSParser',array('url' => 'http://thestar.com.my.feedsportal.com/c/33048/f/534555/index.rss', 'life' => 2));
$data = $this->RSSParser->getFeed(6);
$this->load->view('home',$data);
}
}
?>
view file
Code:
<?php
foreach ($data as $item) :
echo $item['title'];
echo $item['description'];
endforeach;
?>
RSSParser file
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class RSSParser
{
/* Feed URI */
var $feed_uri;
/* Associative array containing all the feed items */
var $data;
/* Store RSS Channel Data in an array */
var $channel_data;
/* Boolean variable which indicates whether an RSS feed was unavailable */
var $feed_unavailable;
// ================ //
// Constructor //
// ================ //
function RSSParser($params) {
$this->CI =& get_instance();
$this->feed_uri = $params['url'];
$this->current_feed["title"] = '';
$this->current_feed["description"] = '';
$this->current_feed["link"] = '';
$this->data = array();
$this->channel_data = array();
//Attempt to parse the feed
$this->parse();
}
// =============== //
// Methods //
// =============== //
function parse() {
//Parse the document
$rawFeed = file_get_contents($this->feed_uri);
$xml = new SimpleXmlElement($rawFeed);
//Assign the channel data
$this->channel_data['title'] = (string) $xml->channel->title;
$this->channel_data['description'] = (string) $xml->channel->description;
//Build the item array
foreach ($xml->channel->item as $item)
{
$data = array();
$data['title'] = (string) $item->title;
$data['description'] = (string) $item->description;
$data['pubDate'] = (string) $item->pubDate;
$data['link'] = (string) $item->link;
$this->data[] = $data;
}
}
/* Return the feeds one at a time: when there are no more feeds return false
* @param No of items to return from the feed
* @return Associative array of items
*/
function getFeed($num) {
$c = 0;
$return = array();
foreach($this->data AS $item)
{
$return[] = $item;
$c++;
if($c == $num) break;
}
return $return;
}
/* Return channel data for the feed */
function & getChannelData() {
$flag = false;
if(!empty($this->channel_data)) {
return $this->channel_data;
} else {
return $flag;
}
}
/* Were we unable to retreive the feeds ? */
function errorInResponse() {
return $this->feed_unavailable;
}
}
my error is
A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for RSSParser::RSSParser(), called in /var/www/html/rssfeed/system/core/Loader.php on line 1011 and defined
Filename: libraries/RSSParser.php
Line Number: 19
and this:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: params
Filename: libraries/RSSParser.php
Line Number: 22
How i can fixed this error and what i need to fixed it ?
thank you, hope you guy can help me soon ^^