Created
January 17, 2012 21:36
-
-
Save AxlH/1629080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Axl Hoogelander | |
* @copyright 2012 | |
*/ | |
class RSS_Feed{ | |
private $url; | |
public function __construct($url){ | |
$this->url = $url; | |
} | |
public function xml() | |
{ | |
$rss = file_get_contents($this->url); | |
if(preg_match('/<rss version="2.0">/', $rss)){ | |
return simplexml_load_string($rss); | |
}else{ | |
echo 'this isnt a rss feed!'; | |
exit(); | |
}return simplexml_load_file($this->url); | |
} | |
public function title(){ | |
return self::xml()->channel->title; | |
} | |
public function content(){ | |
return self::xml()->channel->item; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment