}
/**
- * Returns the requested info fields for the requested set of users.
- *
- * @param string $uids A comma-separated list of user ids
- * @param string $fields A comma-separated list of info field names desired
- *
- * @return array An array of user objects
- */
- public function &users_getInfo($uids, $fields)
- {
- return $this->call_method('facebook.users.getInfo',
- array('uids' => $uids, 'fields' => $fields));
- }
-
- /**
- * Returns the requested info fields for the requested set of users. A
- * session key must not be specified. Only data about users that have
- * authorized your application will be returned.
- *
- * Check the wiki for fields that can be queried through this API call.
- * Data returned from here should not be used for rendering to application
- * users, use users.getInfo instead, so that proper privacy rules will be
- * applied.
- *
- * @param string $uids A comma-separated list of user ids
- * @param string $fields A comma-separated list of info field names desired
- *
- * @return array An array of user objects
- */
- public function &users_getStandardInfo($uids, $fields)
- {
- return $this->call_method('facebook.users.getStandardInfo',
- array('uids' => $uids, 'fields' => $fields));
- }
-
- /**
- * Returns the user corresponding to the current session object.
- *
- * @return integer User id
- */
- public function &users_getLoggedInUser()
- {
- return $this->call_method('facebook.users.getLoggedInUser',
- array('session_key' => $this->auth->getSessionKey()));
- }
-
- /**
- * Returns 1 if the user has the specified permission, 0 otherwise.
- * http://wiki.developers.facebook.com/index.php/Users.hasAppPermission
- *
- * @return integer 1 or 0
- */
- public function &users_hasAppPermission($ext_perm, $uid = null)
- {
- return $this->call_method('facebook.users.hasAppPermission',
- array('ext_perm' => $ext_perm, 'uid' => $uid));
- }
-
- /**
- * Returns whether or not the user corresponding to the current
- * session object has the give the app basic authorization.
- *
- * @return boolean true if the user has authorized the app
- */
- public function &users_isAppUser($uid = null, $sid = null)
- {
- if (empty($uid) && !empty($sid)) {
- $params = array('session_key' => $sid);
- } elseif (!empty($uid)) {
- $params = array('uid' => $uid);
- } else {
- throw new InvalidArgumentException('isAppUser requires either a uid or a session_key');
- }
- return $this->call_method('facebook.users.isAppUser', array('uid' => $uid));
- }
-
- /**
- * Returns whether or not the user corresponding to the current
- * session object is verified by Facebook. See the documentation
- * for Users.isVerified for details.
- *
- * @return boolean true if the user is verified
- */
- public function &users_isVerified()
- {
- return $this->call_method('facebook.users.isVerified');
- }
-
- /**
- * Sets the users' current status message. Message does NOT contain the
- * word "is" , so make sure to include a verb.
- *
- * Example: setStatus("is loving the API!")
- * will produce the status "Luke is loving the API!"
- *
- * @param string $status text-only message to set
- * @param int $uid user to set for (defaults to the
- * logged-in user)
- * @param bool $clear whether or not to clear the status,
- * instead of setting it
- * @param bool $status_includes_verb if true, the word "is" will *not* be
- * prepended to the status message
- *
- * @return boolean
- */
- public function &users_setStatus($status,
- $uid = null,
- $clear = false,
- $status_includes_verb = true)
- {
- $args = array(
- 'status' => $status,
- 'uid' => $uid,
- 'clear' => $clear,
- 'status_includes_verb' => $status_includes_verb,
- );
- return $this->call_method('facebook.users.setStatus', $args);
- }
-
- /**
* Calls the specified normal POST method with the specified parameters.
*
* @param string $method Name of the Facebook method to invoke
--- /dev/null
+<?php
+/**
+ * Users methods for Horde_Service_Facebook
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @package Horde_Service_Facebook
+ */
+class Horde_Service_Facebook_Users extends Horde_Service_Facebook_Base
+{
+ /**
+ * Returns the requested info fields for the requested set of users.
+ *
+ * @param string $uids A comma-separated list of user ids
+ * @param string $fields A comma-separated list of info field names desired
+ *
+ * @return array An array of user objects
+ */
+ public function &getInfo($uids, $fields)
+ {
+ return $this->_facebook->call_method('facebook.users.getInfo',
+ array('uids' => $uids,
+ 'fields' => $fields,
+ 'session_key' => $this->_sessionKey));
+ }
+
+ /**
+ * Returns the requested info fields for the requested set of users. A
+ * session key must not be specified. Only data about users that have
+ * authorized your application will be returned.
+ *
+ * Check the wiki for fields that can be queried through this API call.
+ * Data returned from here should not be used for rendering to application
+ * users, use users.getInfo instead, so that proper privacy rules will be
+ * applied.
+ *
+ * @param string $uids A comma-separated list of user ids
+ * @param string $fields A comma-separated list of info field names desired
+ *
+ * @return array An array of user objects
+ */
+ public function &getStandardInfo($uids, $fields)
+ {
+ return $this->_facebook->call_method('facebook.users.getStandardInfo',
+ array('uids' => $uids, 'fields' => $fields));
+ }
+
+ /**
+ * Returns the user corresponding to the current session object.
+ *
+ * @throws Horde_Service_Facebook_Exception
+ * @return integer User id
+ */
+ public function &getLoggedInUser()
+ {
+ if (empty($this->_sessionKey)) {
+ throw new Horde_Service_Facebook_Exception('users.getLoggedInUser requires a session_key',
+ Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
+ }
+
+ return $this->_facebook->call_method('facebook.users.getLoggedInUser',
+ array('session_key' => $this->_sessionKey));
+ }
+
+ /**
+ * Returns 1 if the user has the specified permission, 0 otherwise.
+ * http://wiki.developers.facebook.com/index.php/Users.hasAppPermission
+ *
+ * @throws Horde_Service_Facebook_Exception
+ * @return integer 1 or 0
+ */
+ public function &hasAppPermission($ext_perm, $uid = null)
+ {
+ if (empty($uid) && empty($this->_sessionKey)) {
+ throw new Horde_Service_Facebook_Exception('users.hasAppPermission requires either a uid or a session_key',
+ Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY)
+ }
+
+ $params = array('ext_perm' => $ext_perm);
+ if (empty($uid)) {
+ $params['session_key'] = $this->_sessionKey;
+ } else {
+ $params['uid'] = $uid;
+ }
+
+ return $this->_facebook->call_method('facebook.users.hasAppPermission', $params);
+ }
+
+ /**
+ * Returns whether or not the user corresponding to the current
+ * session object has the give the app basic authorization.
+ *
+ * @throws Horde_Service_Facebook_Exception
+ * @return boolean true if the user has authorized the app
+ */
+ public function &isAppUser($uid = null)
+ {
+ if (empty($uid) && !empty($this->_sessionKey)) {
+ $params = array('session_key' => $this->_sessionKey);
+ } elseif (!empty($uid)) {
+ $params = array('uid' => $uid);
+ } else {
+ throw new Horde_Service_Facebook_Exception('users.isAppUser requires either a uid or a session_key',
+ Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
+ }
+
+ return $this->_facebook->call_method('facebook.users.isAppUser', $params);
+ }
+
+ /**
+ * Returns whether or not the user corresponding to the current
+ * session object is verified by Facebook. See the documentation
+ * for Users.isVerified for details.
+ *
+ * @throws Horde_Service_Facebook_Exception
+ * @return boolean true if the user is verified
+ */
+ public function &isVerified()
+ {
+ if (empty($this->_sessionKey)) {
+ throw new Horde_Service_Facebook_Exception('users.isVerified requires a session_key',
+ Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
+ }
+
+ return $this->call_method('facebook.users.isVerified', array('session_key' => $this->_sessionKey));
+ }
+
+ /**
+ * Sets the users' current status message. Message does NOT contain the
+ * word "is" , so make sure to include a verb.
+ *
+ * Example: setStatus("is loving the API!")
+ * will produce the status "Luke is loving the API!"
+ *
+ * @param string $status text-only message to set
+ * @param int $uid user to set for (defaults to the
+ * logged-in user)
+ * @param bool $clear whether or not to clear the status,
+ * instead of setting it
+ * @param bool $status_includes_verb if true, the word "is" will *not* be
+ * prepended to the status message
+ *
+ * @return boolean
+ */
+ public function &users_setStatus($status, $uid = null, $clear = false, $includeVerb = true)
+ {
+ if (empty($uid) && empty($this->_sessionKey)) {
+ throw new Horde_Service_Facebook_Exception('users.setStatus requires a uid or a session_key',
+ Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
+ }
+ $params = array('status' => $status,
+ 'clear' => $clear,
+ 'status_includes_verb' => $includeVerb);
+
+ if (empty($uid)) {
+ $params['uid'] = $uid;
+ } else {
+ $params['session_key'] = $this->_sessionKey;
+ }
+
+ return $this->_facebook->call_method('facebook.users.setStatus', $params);
+ }
+
+}
\ No newline at end of file
<file name="Fql.php" role="php" />
<file name="Friends.php" role="php" />
<file name="Notifications.php" role="php" />
- <file name="Exception.php" role="php" />
- <file name="ErrorCodes.php" role="php" />
+ <file name="Users.php" role="php" />
<file name="Request.php" role="php" />
<file name="BatchRequest.php" role="php" />
<file name="Auth.php" role="php" />
+ <file name="Exception.php" role="php" />
+ <file name="ErrorCodes.php" role="php" />
</dir> <!-- /lib/Horde/Service/Facebook -->
<file name="Facebook.php" role="php" />
</dir> <!-- /lib/Horde/Service -->
<install name="lib/Horde/Service/Facebook/Fql.php" as="Horde/Service/Facebook/Fql.php" />
<install name="lib/Horde/Service/Facebook/Friends.php" as="Horde/Service/Facebook/Friends.php" />
<install name="lib/Horde/Service/Facebook/Notifications.php" as="Horde/Service/Facebook/Notifications.php" />
- <install name="lib/Horde/Service/Facebook/Exception.php" as="Horde/Service/Facebook/Exception.php" />
- <install name="lib/Horde/Service/Facebook/ErrorCodes.php" as="Horde/Service/Facebook/ErrorCodes.php" />
+ <install name="lib/Horde/Service/Facebook/Users.php" as="Horde/Service/Facebook/Users.php" />
<install name="lib/Horde/Service/Facebook/Request.php" as="Horde/Service/Facebook/Request.php" />
<install name="lib/Horde/Service/Facebook/BatchRequest.php" as="Horde/Service/Facebook/BatchRequest.php" />
- <install name="lib/Horde/Service/Facebook/Auth.php" as="Horde/Service/Facebook/Auth.php" />
+ <install name="lib/Horde/Service/Facebook/Auth.php" as="Horde/Service/Facebook/Auth.php" />
+ <install name="lib/Horde/Service/Facebook/Exception.php" as="Horde/Service/Facebook/Exception.php" />
+ <install name="lib/Horde/Service/Facebook/ErrorCodes.php" as="Horde/Service/Facebook/ErrorCodes.php" />
<install name="lib/Horde/Service/Facebook.php" as="Horde/Service/Facebook.php" />
</filelist>
</phprelease>