Skip to content

Instantly share code, notes, and snippets.

@adionditsak
Last active December 14, 2015 16:29
Show Gist options
  • Save adionditsak/5115324 to your computer and use it in GitHub Desktop.
Save adionditsak/5115324 to your computer and use it in GitHub Desktop.
<?php
/*
*
* Get your Facebook-statuses and Twitter-tweets on your website with ease.
* Go to http://feedburner.com and burn your feed.
* Use your feedburner-url with this class to set feed.
*
* Author: Anders Aarvik
*
*/
class getFeedburner {
public function setFeed($feedURL) {
$this->xml_feed = $feedURL;
$this->doc = new DOMDocument();
$this->doc->load($this->xml_feed);
$this->feeds = array();
$this->limit = 10;
$this->counter = 0;
foreach ($this->doc->getElementsByTagName('item') as $node) {
if($this->counter <= $this->limit) {
$this->items = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'pubDate' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
);
array_push($this->feeds, $this->items);
}
$this->counter++;
}
}
public function getFeed() {
foreach ($this->feeds as $feed) {
$this->date = strtotime($feed['pubDate']);
echo $feed['description'] . '<br/>';
echo '<a href="' . $feed['link'] . '">Se mere</a>';
echo '<br/><br/>';
echo date('jS F Y G:H', $this->date);
echo '<hr/>';
}
}
}
?>
<?php require 'getFeedburner.class.php'; ?>
<?php
//Facebook output
$getFacebookFeed = new getFeedburner();
$getFacebookFeed->setFeed("http://feeds.feedburner.com/...");
$getFacebookFeed->getFeed();
//Twitter output
$getTwitterFeed = new getFeedburner();
$getTwitterFeed->setFeed("http://feeds.feedburner.com/...");
$getTwitterFeed->getFeed();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment