From 3f01a658f62ccbba4d0632e9e143895463891151 Mon Sep 17 00:00:00 2001 From: Thomas Muguet Date: Wed, 1 May 2013 02:12:45 +0200 Subject: [PATCH] Added spout for Facebook page feed --- spouts/facebook/page.php | 83 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 spouts/facebook/page.php diff --git a/spouts/facebook/page.php b/spouts/facebook/page.php new file mode 100644 index 0000000000..c46d02d2bf --- /dev/null +++ b/spouts/facebook/page.php @@ -0,0 +1,83 @@ + + */ +class page extends \spouts\rss\feed { + + /** + * name of source + * + * @var string + */ + public $name = 'Facebook page feed'; + + + /** + * description of this source type + * + * @var string + */ + public $description = 'Page wall'; + + + /** + * config params + * array of arrays with name, type, default value, required, validation type + * + * - Values for type: text, password, checkbox + * - Values for validation: alpha, email, numeric, int, alnum, notempty + * + * e.g. + * array( + * "id" => array( + * "title" => "URL", + * "type" => "text", + * "default" => "", + * "required" => true, + * "validation" => array("alnum") + * ), + * .... + * ) + * + * @var bool|mixed + */ + public $params = array( + "user" => array( + "title" => "Page name", + "type" => "text", + "default" => "", + "required" => true, + "validation" => array("notempty") + ) + ); + + + + // + // Source Methods + // + + + /** + * loads content for given source + * I supress all Warnings of SimplePie for ensuring + * working plugin in PHP Strict mode + * + * @return void + * @param mixed $params the params of this source + */ + public function load($params) { + $info = json_decode(file_get_contents("https://graph.facebook.com/" . $params['user']), TRUE); + + $rssParams = array("url" => "https://www.facebook.com/feeds/page.php?format=atom10&id=" . $info['id']); + return parent::load($rssParams); + } +}