From e249e6c2c176006af99c8c7500c73c6fa5525b6e Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Wed, 29 Apr 2009 15:54:43 -0400 Subject: [PATCH] Implement Streams.publish - it's now fairly easy to publish "actions" to facebook triggered by horde interactions...like uploading new images to an ansel gallery, or making a new news article in jonah etc... --- .../lib/Horde/Service/Facebook/Streams.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook/Streams.php b/framework/Service_Facebook/lib/Horde/Service/Facebook/Streams.php index 7fa1c0b13..9e3d583c5 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook/Streams.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook/Streams.php @@ -29,7 +29,7 @@ class Horde_Service_Facebook_Streams extends Horde_Service_Facebook_Base $limit = '', $filterKey = '') { if (empty($viewerId) && !$session_key = $this->_facebook->auth->getSessionKey()) { - throw new Horde_Service_Facebook_Exception('users.hasAppPermission requires either a uid or a session_key', + throw new Horde_Service_Facebook_Exception('Streams.publish requires either a uid or a session_key', Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY); } $params = array('viewer_id' => $viewerId, @@ -75,9 +75,27 @@ class Horde_Service_Facebook_Streams extends Horde_Service_Facebook_Base * @param string $action_links Array of action links. * @param string $target_id The id of user/page you are publishing to. */ - function publish($message = '', $attachment = '', $action_links = '', $target_id = '') + function publish($message = '', $attachment = '', $action_links = '', $target_id = '', $uid = '') { + if (empty($uid) && !$session_key = $this->_facebook->auth->getSessionKey()) { + throw new Horde_Service_Facebook_Exception('Streams.publish requires either a uid or a session_key', + Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY); + } + + $params = array('message' => $message, + 'action_links' => $action_links, + 'target_id' => $target_id); + if (!empty($uid)) { + $params['uid'] = $uid; + } + if (!empty($session_key)) { + $params['session_key'] = $session_key; + } + if (!empty($attachment)) { + $params['attachment'] = json_encode($attachment); + } + return $this->_facebook->callMethod('Stream.publish', $params); } /** -- 2.11.0