Rss parser library codeigniter
I wrote a codeigniter library through which you can retrieve the rss feeds from xml file
Add the below code in Rss.php file and save the file in application library folder ,
-
/**
-
* CodeIgniter
-
*
-
* An open source application development framework for PHP 4.3.2 or newer
-
*
-
* @package CodeIgniter
-
* @author Pradeep Kumar
-
* @copyright Copyright (c) 2009, hyderabad, Inc.
-
* @license http://tech-pundits.com/license.html
-
* @link http://tech-pundits.com
-
* @since Version 1.0
-
* @filesource
-
*/
-
-
// ————————————————————————
-
-
/**
-
* Rss Class
-
*
-
* @package CodeIgniter
-
* @subpackage Libraries
-
* @category Rss Parser
-
* @author Pradeep Kumar
-
*/
-
class Rss {
-
public $url = ""; // saves the rss feed url
-
private $aFiledata = ""; // saves the file data in array format
-
private $sFiledata = "";
-
private $item = "";
-
private $entry = "";
-
private $title = "";
-
private $link = "";
-
private $data = "";
-
private $description = "";
-
private $date = "";
-
private $date_gmt = "";
-
private $image = "";
-
private $result;
-
/**
-
* @return unknown
-
*/
-
public function getAFiledata() {
-
return $this->aFiledata;
-
}
-
/**
-
* @return unknown
-
*/
-
public function getEntry() {
-
return $this->entry;
-
}
-
/**
-
* @return unknown
-
*/
-
public function getItem() {
-
return $this->item;
-
}
-
/**
-
* @return unknown
-
*/
-
public function getSFiledata() {
-
return $this->sFiledata;
-
}
-
/**
-
* @return unknown
-
*/
-
public function getTitle() {
-
return $this->title;
-
}
-
/**
-
* @return unknown
-
*/
-
public function getUrl() {
-
return $this->url;
-
}
-
-
/**
-
* @return unknown
-
*/
-
public function getData() {
-
return $this->data;
-
}
-
-
/**
-
* @return unknown
-
*/
-
public function getDescription() {
-
return $this->description;
-
}
-
-
/**
-
* @return unknown
-
*/
-
return $this->date;
-
}
-
/**
-
* @return unknown
-
*/
-
public function getDate_gmt() {
-
return $this->date_gmt;
-
}
-
-
/**
-
* @return unknown
-
*/
-
public function getImage() {
-
return $this->image;
-
}
-
-
/**
-
* @return unknown
-
*/
-
public function getResult() {
-
return $this->result;
-
}
-
-
/**
-
* @param unknown_type $result
-
*/
-
public function setResult($result) {
-
$this->result = $result;
-
}
-
-
/**
-
* @param unknown_type $image
-
*/
-
public function setImage($image) {
-
$this->image = $image;
-
}
-
-
/**
-
* @param unknown_type $date_gmt
-
*/
-
public function setDate_gmt($date_gmt) {
-
$this->date_gmt = $date_gmt;
-
}
-
-
/**
-
* @return unknown
-
*/
-
public function getLink() {
-
return $this->link;
-
}
-
-
/**
-
* @param unknown_type $link
-
*/
-
public function setLink($link) {
-
$this->link = $link;
-
}
-
-
/**
-
* @param unknown_type $date
-
*/
-
public function setDate($date) {
-
$this->date = $date;
-
}
-
/**
-
* @param unknown_type $data
-
*/
-
public function setData($data) {
-
$this->data = $data;
-
}
-
-
/**
-
* @param unknown_type $description
-
*/
-
public function setDescription($description) {
-
$this->description = $description;
-
}
-
-
/**
-
* @param unknown_type $aFiledata
-
*/
-
public function setAFiledata($aFiledata) {
-
$this->aFiledata = $aFiledata;
-
}
-
-
/**
-
* @param unknown_type $Entry
-
*/
-
public function setEntry($entry) {
-
$this->entry = $entry;
-
}
-
-
/**
-
* @param unknown_type $Item
-
*/
-
public function setItem($item) {
-
$this->item = $item;
-
}
-
-
/**
-
* @param unknown_type $sFiledata
-
*/
-
public function setSFiledata($sFiledata) {
-
$this->sFiledata = $sFiledata;
-
}
-
-
/**
-
* @param unknown_type $Title
-
*/
-
public function setTitle($title) {
-
$this->title = $title;
-
}
-
-
/**
-
* @param unknown_type $Url
-
*/
-
public function setUrl($url) {
-
$this->url = $url;
-
}
-
-
-
/**
-
* Constructor
-
*
-
* @access public
-
* @param array initialization parameters
-
*/
-
{
-
{
-
$this->initialize($params);
-
}
-
-
log_message("debug", "Rss Class Initialized");
-
}
-
-
// ——————————————————————–
-
-
/**
-
* Initialize Preferences
-
*
-
* @access public
-
* @param array initialization parameters
-
* @return void
-
*/
-
{
-
{
-
foreach ($params as $key => $val)
-
{
-
{
-
$this->$key = $val;
-
}
-
}
-
}
-
}
-
-
-
function getRss()
-
{
-
return $this->run();
-
-
}
-
-
function run()
-
{
-
$items = $this->getItem();
-
$this->setItem($items[0]);
-
$this->setData("<table>");
-
{
-
$items = $this->getItem();
-
$this->setItem($items[0]);
-
$this->setData("</table><table>");
-
}
-
foreach ($this->getItem() as $item)
-
{
-
$this->setTitle(strip_tags(str_replace(array("< ![CDATA[', ']]>"), array("",""), trim($this->title[1]))));
-
if ($this->date_gmt) {
-
} else {
-
{
-
}
-
}
-
if($this->getDate_gmt())
-
{
-
$this->setDate($this->getDate_gmt());
-
}
-
{
-
$this->setImage($this->image[1]);
-
}
-
else
-
$this->image = "";
-
if($this->getDescription())
-
{
-
}
-
else
-
{
-
if($this->getDescription())
-
{
-
}
-
else
-
$this->setDescription("");
-
}
-
{
-
{
-
$img ="";
-
$this->setDescription($img[1].$this->getDescription());
-
}
-
$this->setLink(str_replace(array("< ![CDATA[', ']]>",‘"/>’), "", trim(strip_tags($this->link[1]))));
-
$this->link;
-
}
-
else
-
{
-
-
}
-
$this->data .= ‘<tr><td> <a title="’.strip_tags($this->getDescription()).‘" href="’.$this->getLink().‘">’.$this->getTitle().‘</a></td><td>’.$this->getDate().‘</td></tr>’;
-
"title" => $this->getTitle(),
-
"link" => $this->getLink(),
-
"date" => $this->getDate(),
-
"image" => $this->getImage(),
-
"description" => $this->getDescription(),
-
);
-
}
-
$this->data .="</link></table>";
-
-
return $this->getResult();
-
}
-
-
}
-
?>
Add the below code in your controller
-
<?php
-
$this->load->libarary("rss");
-
$config["utl"]="rsslink";
-
$this->rss->initialize($config);
-
$result = $this->rss->getRss();
-
?>
Click here to download code
Dear Author http://www.programmersguide.net !
I join. I agree with told all above.