--- /dev/null
+<?php
+/**
+ * Feed methods
+ */
+
+class Horde_Service_Facebook_Feeds extends Horde_Service_Facebook_Base
+{
+ const STORY_SIZE_ONE_LINE = 1;
+ const STORY_SIZE_SHORT = 2;
+ const STORY_SIZE_FULL = 4;
+
+ /**
+ * Registers a template bundle. Template bundles are somewhat involved, so
+ * it's recommended you check out the wiki for more details:
+ *
+ * http://wiki.developers.facebook.com/index.php/Feed.registerTemplateBundle
+ *
+ * @return string A template bundle id
+ */
+ public function ®isterTemplateBundle($oneLineStory,
+ $shortStory = array(),
+ $fullStory = null,
+ $actionLinks = array())
+ {
+ $oneLineStory = json_encode($oneLineStory);
+
+ if (!empty($shortStory)) {
+ $shortStory = json_encode($shortStory);
+ }
+
+ if (isset($fullStory)) {
+ $fullStory = json_encode($fullStory);
+ }
+
+ if (isset($actionLinks)) {
+ $actionLinks = json_encode($actionLinks);
+ }
+
+ return $this->_facebook->call_method('facebook.feed.registerTemplateBundle',
+ array('one_line_story_templates' => $oneLineStory,
+ 'short_story_templates' => $shortStory,
+ 'full_story_template' => $fullStory,
+ 'action_links' => $actionLinks));
+ }
+
+ /**
+ * Retrieves the full list of active template bundles registered by the
+ * requesting application.
+ *
+ * @return array An array of template bundles
+ */
+ public function &getRegisteredTemplateBundles()
+ {
+ return $this->_facebook->call_method('facebook.feed.getRegisteredTemplateBundles');
+ }
+
+ /**
+ * Retrieves information about a specified template bundle previously
+ * registered by the requesting application.
+ *
+ * @param string $id The template bundle id
+ *
+ * @return array Template bundle
+ */
+ public function &getRegisteredTemplateBundleByID($id)
+ {
+ return $this->_facebook->call_method('facebook.feed.getRegisteredTemplateBundleByID',
+ array('template_bundle_id' => $id));
+ }
+
+ /**
+ * Deactivates a previously registered template bundle.
+ *
+ * @param string $template_bundle_id The template bundle id
+ *
+ * @return bool true on success
+ */
+ public function &deactivateTemplateBundleByID($id)
+ {
+ return $this->_facebook->call_method('facebook.feed.deactivateTemplateBundleByID',
+ array('template_bundle_id' => $id));
+ }
+
+ /**
+ * Publishes a story on behalf of the user owning the session, using the
+ * specified template bundle. This method requires an active session key in
+ * order to be called.
+ *
+ * The parameters to this method ($templata_data in particular) are somewhat
+ * involved. It's recommended you visit the wiki for details:
+ *
+ * http://wiki.developers.facebook.com/index.php/Feed.publishUserAction
+ *
+ * @param int $bundleId A template bundle id previously registered
+ * @param array $data See wiki article for syntax
+ * @param array $targetIds (Optional) An array of friend uids of the user
+ * who shared in this action.
+ * @param string $body (Optional) Additional markup that extends
+ * the body of a short story.
+ * @param int $size (Optional) A story size (see above)
+ *
+ * @return bool true on success
+ */
+ public function &publishUserAction($bundleId, $data, $targetIds = '',
+ $body = '', $size = self::STORY_SIZE_ONE_LINE)
+ {
+ // Pass in JSON or an assoc that we JSON for them
+ if (is_array($data)) {
+ $data = json_encode($data);
+ }
+ if (is_array($targetIds)) {
+ $targetIds = json_encode($targetIds);
+ // No brackets
+ $targetIds = trim($targetIds, "[]");
+ }
+
+ return $this->_facebook->call_method('facebook.feed.publishUserAction',
+ array('template_bundle_id' => $bundleId,
+ 'template_data' => $data,
+ 'target_ids' => $targetIds,
+ 'body_general' => $body,
+ 'story_size' => $size));
+ }
+
+ /**
+ * For the current user, retrieves stories generated by the user's friends
+ * while using this application. This can be used to easily create a
+ * "News Feed" like experience.
+ *
+ * @return array An array of feed story objects.
+ */
+ public function &feed_getAppFriendStories()
+ {
+ return $this->_facebook->call_method('facebook.feed.getAppFriendStories');
+ }
+
+}
\ No newline at end of file