From 051b50a39fcfc7037207debb7e21d4b9eaa9c45b Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Fri, 6 Mar 2009 16:27:03 -0500 Subject: [PATCH] Allow passing *real* arrays to methods that take a "facebook array" and make sure we json encode the array before sending it up. --- .../lib/Horde/Service/Facebook/Notifications.php | 10 +++++++--- .../Service_Facebook/lib/Horde/Service/Facebook/Request.php | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook/Notifications.php b/framework/Service_Facebook/lib/Horde/Service/Facebook/Notifications.php index e0e867177..1b33d4654 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook/Notifications.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook/Notifications.php @@ -33,9 +33,13 @@ class Horde_Service_Facebook_Notifications extends Horde_Service_Facebook_Base /** * Sends a notification to the specified users. * + * @param mixed $to_ids Either an array of uids or a string + * delimited list of uids. + * @param string $notification A FBML string for the notification. + * @param string $type Either 'user_to_user' or 'app_to_user' + * * @throws Horde_Service_Facebook_Exception * @return A comma separated list of successful recipients - * @error API_EC_PARAM_USER_ID_LIST */ public function &send($to_ids, $notification, $type) { @@ -45,7 +49,7 @@ class Horde_Service_Facebook_Notifications extends Horde_Service_Facebook_Base Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED); } - return $this->callMethod('facebook.notifications.send', + return $this->_facebook->callMethod('facebook.notifications.send', array('to_ids' => $to_ids, 'notification' => $notification, 'type' => $type, @@ -72,7 +76,7 @@ class Horde_Service_Facebook_Notifications extends Horde_Service_Facebook_Base throw new Horde_Service_Facebook_Exception('session_key is required', Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED); } - return $this->callMethod('facebook.notifications.sendEmail', + return $this->_facebook->callMethod('facebook.notifications.sendEmail', array('recipients' => $recipients, 'subject' => $subject, 'text' => $text, diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook/Request.php b/framework/Service_Facebook/lib/Horde/Service/Facebook/Request.php index fffeb1f7c..157d13e84 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook/Request.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook/Request.php @@ -86,6 +86,15 @@ class Horde_Service_Facebook_Request */ protected function _finalizeParams($method, &$params) { + // Run through the params and see if any of them are arrays. If so, + // json encode them, as per the new Facebook API guidlines. + // http://www.facebook.com/developers/message.php#msg_351 + foreach ($params as &$param) { + if (is_array($parm)) { + $param = json_endcode($param); + } + } + $this->_addStandardParams($method, $params); // we need to do this before signing the params $this->_convertToCsv($params); -- 2.11.0