Overview

Packages

  • None
  • Service
    • Facebook

Classes

  • Horde_Service_Facebook_Auth
  • Horde_Service_Facebook_Base
  • Horde_Service_Facebook_BatchRequest
  • Horde_Service_Facebook_ErrorCodes
  • Horde_Service_Facebook_Events
  • Horde_Service_Facebook_Exception
  • Horde_Service_Facebook_Fql
  • Horde_Service_Facebook_Friends
  • Horde_Service_Facebook_Groups
  • Horde_Service_Facebook_Links
  • Horde_Service_Facebook_Notes
  • Horde_Service_Facebook_Notifications
  • Horde_Service_Facebook_Photos
  • Horde_Service_Facebook_Request
  • Horde_Service_Facebook_Streams
  • Horde_Service_Facebook_Translation
  • Horde_Service_Facebook_UploadRequest
  • Horde_Service_Facebook_Users
  • Horde_Service_Facebook_Videos
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Users methods for Horde_Service_Facebook
  4:  *
  5:  * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  8:  * @category Horde
  9:  * @package Service_Facebook
 10:  */
 11: class Horde_Service_Facebook_Users extends Horde_Service_Facebook_Base
 12: {
 13:     /**
 14:      * Returns the requested info fields for the requested set of users.
 15:      *
 16:      * @param string $uids    A comma-separated list of user ids
 17:      * @param string $fields  A comma-separated list of info field names desired
 18:      *
 19:      * @return array  An array of user objects
 20:      */
 21:     public function &getInfo($uids, $fields)
 22:     {
 23:         return $this->_facebook->callMethod('facebook.users.getInfo',
 24:             array('uids' => $uids,
 25:                   'fields' => $fields,
 26:                   'session_key' => $this->_facebook->auth->getSessionKey()));
 27:     }
 28: 
 29:     /**
 30:      * Returns the requested info fields for the requested set of users. A
 31:      * session key must not be specified. Only data about users that have
 32:      * authorized your application will be returned.
 33:      *
 34:      * Check the wiki for fields that can be queried through this API call.
 35:      * Data returned from here should *not* be used for rendering to application
 36:      * users, use users.getInfo instead, so that proper privacy rules will be
 37:      * applied.
 38:      *
 39:      * @param string $uids    A comma-separated list of user ids
 40:      * @param string $fields  A comma-separated list of info field names desired
 41:      *
 42:      * @return array  An array of user objects
 43:      */
 44:     public function &getStandardInfo($uids, $fields)
 45:     {
 46:         return $this->_facebook->callMethod('facebook.users.getStandardInfo',
 47:             array('uids' => $uids, 'fields' => $fields));
 48:     }
 49: 
 50:     /**
 51:      * Returns 1 if the user has the specified permission, 0 otherwise.
 52:      * http://wiki.developers.facebook.com/index.php/Users.hasAppPermission
 53:      *
 54:      * @param string $ext_perm  The perm to check for.
 55:      * @param string $uid       The facebook userid to check.
 56:      *
 57:      * @return integer  1 or 0
 58:      * @throws Horde_Service_Facebook_Exception
 59:      */
 60:     public function &hasAppPermission($ext_perm, $uid = null)
 61:     {
 62:         if (empty($uid) && !$this->_facebook->auth->getSessionKey()) {
 63:             throw new Horde_Service_Facebook_Exception('users.hasAppPermission requires either a uid or a session_key',
 64:                 Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
 65:         }
 66: 
 67:         $params = array('ext_perm' => $ext_perm);
 68:         if (!empty($uid)) {
 69:             $params['uid'] = $uid;
 70:         }
 71: 
 72:         return $this->_facebook->callMethod('facebook.users.hasAppPermission', $params);
 73:     }
 74: 
 75:     /**
 76:      * Returns whether or not the user corresponding to the current
 77:      * session object has the give the app basic authorization.
 78:      *
 79:      * @TODO Deprecate when Graph API provides this functionality.
 80:      *
 81:      * @param string $uid  Facebook userid
 82:      *
 83:      * @return boolean  true if the user has authorized the app
 84:      * @throws Horde_Service_Facebook_Exception
 85:      */
 86:     public function &isAppUser($uid = null)
 87:     {
 88:         if (empty($uid) && $this->_facebook->auth->getSessionKey()) {
 89:             $params = array('session_key' => $this->_facebook->auth->getSessionKey());
 90:         } elseif (!empty($uid)) {
 91:             $params = array('uid' => $uid);
 92:         } else {
 93:             throw new Horde_Service_Facebook_Exception('users.isAppUser requires either a uid or a session_key',
 94:                 Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
 95:         }
 96: 
 97:         return $this->_facebook->callMethod('facebook.users.isAppUser', $params);
 98:     }
 99: 
100:     /**
101:      * Returns whether or not the user corresponding to the current
102:      * session object is verified by Facebook. See the documentation
103:      * for Users.isVerified for details.
104:      *
105:      * @throws Horde_Service_Facebook_Exception
106:      * @return boolean  true if the user is verified
107:      */
108:     public function &isVerified()
109:     {
110:        if (!$this->_facebook->auth->getSessionKey()) {
111:             throw new Horde_Service_Facebook_Exception('users.isVerified requires a session_key',
112:                 Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
113:         }
114: 
115:         return $this->callMethod('facebook.users.isVerified', array('session_key' => $this->_facebook->auth->getSessionKey()));
116:     }
117: 
118:     /**
119:      * Sets the users' current status message. Message does NOT contain the
120:      * word "is" , so make sure to include a verb.
121:      *
122:      * Example: setStatus("is loving the API!")
123:      * will produce the status "Luke is loving the API!"
124:      *
125:      * @param string  $status      text-only message to set
126:      * @param string  $uid         user to set for (defaults to the
127:      *                             logged-in user)
128:      * @param boolean $clear       whether or not to clear the status, instead
129:      *                             of setting it
130:      * @param boolean $includeVerb If true, the word "is" will *not* be
131:      *                             prepended to the status message
132:      *
133:      * @return boolean
134:      */
135:     public function &setStatus($status, $uid = null, $clear = false, $includeVerb = true)
136:     {
137:         if (empty($uid) && !$skey = $this->_facebook->auth->getSessionKey()) {
138:             throw new Horde_Service_Facebook_Exception('users.setStatus requires a uid or a session_key',
139:                 Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
140:         }
141:         $params  = array('status' => $status,
142:                          'clear' => $clear,
143:                          'status_includes_verb' => $includeVerb);
144: 
145:         if (!empty($uid)) {
146:             $params['uid'] = $uid;
147:         } else {
148:             $params['session_key']  = $skey;
149:         }
150: 
151:         return $this->_facebook->callMethod('facebook.users.setStatus', $params);
152:     }
153: 
154:     /**
155:      * Get user's status
156:      *
157:      * @param string  $uid
158:      * @param integer $limit
159:      *
160:      * @return mixed
161:      */
162:     public function &getStatus($uid = null, $limit = 1)
163:     {
164:         $skey = $this->_facebook->auth->getSessionKey();
165:         if (empty($uid) && !$skey) {
166:             throw new Horde_Service_Facebook_Exception('users.setStatus requires a uid or a session_key',
167:                 Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
168:         }
169: 
170:         $params = array('session_key' => $skey, 'limit' => $limit);
171:         if (!empty($uid)) {
172:             $params['uid'] = $uid;
173:         }
174: 
175:         return $this->_facebook->callMethod('Status.get', $params);
176:     }
177: 
178: }
API documentation generated by ApiGen