ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/facebook/trunk/facebookapi_php5_restlib.php
(Generate patch)

Comparing facebook/trunk/facebookapi_php5_restlib.php (file contents):
Revision 956 by douglas, 2007-10-11T02:45:01-07:00 vs.
Revision 959 by douglas, 2007-11-13T15:22:57-08:00

# Line 48 | Line 48 | class FacebookRestClient {
48  
49    /**
50     * Create the client.
51 <   * @param string $session_key if you haven't gotten a session key yet, leave
52 <   *                            this as null and then set it later by just
53 <   *                            directly accessing the $session_key member
51 >   * @param string $session_key if you haven't gotten a session key yet, leave
52 >   *                            this as null and then set it later by just
53 >   *                            directly accessing the $session_key member
54     *                            variable.
55     */
56    public function __construct($api_key, $secret, $session_key=null) {
# Line 81 | Line 81 | function toggleDisplay(id, type) {
81  
82    /**
83     * Returns the session information available after current user logs in.
84 <   * @param string $auth_token the token returned by auth_createToken or
84 >   * @param string $auth_token the token returned by auth_createToken or
85     *  passed back to your callback_url.
86     * @return assoc array containing session_key, uid
87     */
# Line 97 | Line 97 | function toggleDisplay(id, type) {
97  
98    /**
99     * Returns events according to the filters specified.
100 <   * @param int $uid Optional: User associated with events.  
100 >   * @param int $uid Optional: User associated with events.
101     *   A null parameter will default to the session user.
102     * @param array $eids Optional: Filter by these event ids.
103     *   A null parameter will get all events for the user.
104 <   * @param int $start_time Optional: Filter with this UTC as lower bound.  
104 >   * @param int $start_time Optional: Filter with this UTC as lower bound.
105     *   A null or zero parameter indicates no lower bound.
106 <   * @param int $end_time Optional: Filter with this UTC as upper bound.
106 >   * @param int $end_time Optional: Filter with this UTC as upper bound.
107     *   A null or zero parameter indicates no upper bound.
108     * @param string $rsvp_status Optional: Only show events where the given uid
109     *   has this rsvp status.  This only works if you have specified a value for
# Line 116 | Line 116 | function toggleDisplay(id, type) {
116          array(
117          'uid' => $uid,
118          'eids' => $eids,
119 <        'start_time' => $start_time,
119 >        'start_time' => $start_time,
120          'end_time' => $end_time,
121          'rsvp_status' => $rsvp_status));
122    }
# Line 144 | Line 144 | function toggleDisplay(id, type) {
144        array('query' => $query));
145    }
146  
147 <  public function feed_publishStoryToUser($title, $body,
147 >  public function feed_publishStoryToUser($title, $body,
148                                            $image_1=null, $image_1_link=null,
149                                            $image_2=null, $image_2_link=null,
150                                            $image_3=null, $image_3_link=null,
# Line 161 | Line 161 | function toggleDisplay(id, type) {
161              'image_4' => $image_4,
162              'image_4_link' => $image_4_link));
163    }
164 <                                          
165 <  public function feed_publishActionOfUser($title, $body,
164 >
165 >  public function feed_publishActionOfUser($title, $body,
166                                             $image_1=null, $image_1_link=null,
167                                             $image_2=null, $image_2_link=null,
168                                             $image_3=null, $image_3_link=null,
# Line 212 | Line 212 | function toggleDisplay(id, type) {
212     * @param array $uids2: array of ids (id_A, id_B,...) of SAME length X
213     * @return array of uid pairs with bool, true if pair are friends, e.g.
214     *   array( 0 => array('uid1' => id_1, 'uid2' => id_A, 'are_friends' => 1),
215 <   *          1 => array('uid1' => id_2, 'uid2' => id_B, 'are_friends' => 0)
215 >   *          1 => array('uid1' => id_2, 'uid2' => id_B, 'are_friends' => 0)
216     *         ...)
217     */
218    public function friends_areFriends($uids1, $uids2) {
219      return $this->call_method('facebook.friends.areFriends',
220          array('uids1'=>$uids1, 'uids2'=>$uids2));
221    }
222 <  
222 >
223    /**
224     * Returns the friends of the current session user.
225     * @return array of friends
# Line 230 | Line 230 | function toggleDisplay(id, type) {
230      }
231      return $this->call_method('facebook.friends.get', array());
232    }
233 <  
233 >
234    /**
235     * Returns the friends of the session user, who are also users
236     * of the calling application.
# Line 242 | Line 242 | function toggleDisplay(id, type) {
242  
243    /**
244     * Returns groups according to the filters specified.
245 <   * @param int $uid Optional: User associated with groups.  
245 >   * @param int $uid Optional: User associated with groups.
246     *  A null parameter will default to the session user.
247     * @param array $gids Optional: group ids to query.
248     *   A null parameter will get all groups for the user.
# Line 258 | Line 258 | function toggleDisplay(id, type) {
258    /**
259     * Returns the membership list of a group
260     * @param int $gid : Group id
261 <   * @return assoc array of four membership lists, with keys
261 >   * @return assoc array of four membership lists, with keys
262     *  'members', 'admins', 'officers', and 'not_replied'
263     */
264    public function groups_getMembers($gid) {
# Line 268 | Line 268 | function toggleDisplay(id, type) {
268  
269    /**
270     * Returns the outstanding notifications for the session user.
271 <   * @return assoc array of
272 <   *  notification count objects for 'messages', 'pokes' and 'shares',
271 >   * @return assoc array of
272 >   *  notification count objects for 'messages', 'pokes' and 'shares',
273     *  a uid list of 'friend_requests', a gid list of 'group_invites',
274     *  and an eid list of 'event_invites'
275     */
# Line 287 | Line 287 | function toggleDisplay(id, type) {
287    }
288  
289    /**
290 <   * Sends a request to the specified user (e.g. "you have 1 event invitation")
291 <   * @param array $to_ids   user ids to receive the request (must be friends with sender, capped at 10)
292 <   * @param string $type    type of request, e.g. "event" (as in "You have an event invitation.")
293 <   * @param string $content fbml content of the request.  really stripped down fbml - just
294 <   *                        text/names/links.  also, use the special tag <fb:req-choice url="" label="" />
295 <   *                        to specify the buttons to be included.
296 <   * @param string $image   url of an image to show beside the request
297 <   * @param bool   $invite  whether to call it an "invitation" or a "request"
298 <   * @return string url which you should send the logged in user to to finalize the message.
290 >   * Returns the requested info fields for the requested set of pages
291 >   * @param array $page_ids an array of page ids
292 >   * @param array $fields an array of strings describing the info fields desired
293 >   * @param int $uid   Optionally, limit results to pages of which this user is a fan.
294 >   * @param string type  limits results to a particular type of page.
295 >   * @return array of pages
296 >   */
297 >  public function pages_getInfo($page_ids, $fields, $uid, $type) {
298 >    return $this->call_method('facebook.pages.getInfo', array('page_ids' => $page_ids, 'fields' => $fields, 'uid' => $uid, 'type' => $type));
299 >  }
300 >
301 >  /**
302 >   * Returns true if logged in user is an admin for the passed page
303 >   * @param int $page_id target page id
304 >   * @return boolean
305     */
306 <  public function notifications_sendRequest($to_ids, $type, $content, $image, $invite) {
307 <    return $this->call_method('facebook.notifications.sendRequest',
308 <                              array('to_ids' => $to_ids, 'type' => $type, 'content' => $content,
309 <                                    'image' => $image, 'invite' => $invite));
306 >  public function pages_isAdmin($page_id) {
307 >    return $this->call_method('facebook.pages.isAdmin', array('page_id' => $page_id));
308 >  }
309 >
310 >  /**
311 >   * Returns whether or not the page corresponding to the current session object has the app installed
312 >   * @return boolean
313 >   */
314 >  public function pages_isAppAdded() {
315 >    if (isset($this->added)) {
316 >      return $this->added;
317 >    }
318 >    return $this->call_method('facebook.pages.isAppAdded', array());
319 >  }
320 >
321 >  /**
322 >   * Returns true if logged in user is a fan for the passed page
323 >   * @param int $page_id target page id
324 >   * @param int $uid user to compare.  If empty, the logged in user.
325 >   * @return bool
326 >   */
327 >  public function pages_isFan($page_id, $uid) {
328 >    return $this->call_method('facebook.pages.isFan', array('page_id' => $page_id, 'uid' => $uid));
329    }
330  
331    /**
332     * Returns photos according to the filters specified.
333     * @param int $subj_id Optional: Filter by uid of user tagged in the photos.
334 <   * @param int $aid Optional: Filter by an album, as returned by
334 >   * @param int $aid Optional: Filter by an album, as returned by
335     *  photos_getAlbums.
336 <   * @param array $pids Optional: Restrict to a list of pids
337 <   * Note that at least one of these parameters needs to be specified, or an
336 >   * @param array $pids Optional: Restrict to a list of pids
337 >   * Note that at least one of these parameters needs to be specified, or an
338     * error is returned.
339     * @return array of photo objects.
340     */
341    public function photos_get($subj_id, $aid, $pids) {
342 <    return $this->call_method('facebook.photos.get',
342 >    return $this->call_method('facebook.photos.get',
343        array('subj_id' => $subj_id, 'aid' => $aid, 'pids' => $pids));
344    }
345  
# Line 327 | Line 352 | function toggleDisplay(id, type) {
352     * @returns an array of album objects.
353     */
354    public function photos_getAlbums($uid, $aids) {
355 <    return $this->call_method('facebook.photos.getAlbums',
355 >    return $this->call_method('facebook.photos.getAlbums',
356        array('uid' => $uid,
357              'aids' => $aids));
358    }
# Line 339 | Line 364 | function toggleDisplay(id, type) {
364     *  and two floating-point numbers (xcoord, ycoord) for tag pixel location
365     */
366    public function photos_getTags($pids) {
367 <    return $this->call_method('facebook.photos.getTags',
367 >    return $this->call_method('facebook.photos.getTags',
368        array('pids' => $pids));
369    }
370  
371    /**
372     * Returns the requested info fields for the requested set of users
373 <   * @param array $uids an array of user ids
373 >   * @param array $uids an array of user ids
374     * @param array $fields an array of strings describing the info fields desired
375     * @return array of users
376     */
# Line 357 | Line 382 | function toggleDisplay(id, type) {
382     * Returns the user corresponding to the current session object.
383     * @return integer uid
384     */
385 <  public function users_getLoggedInUser(){
385 >  public function users_getLoggedInUser() {
386      return $this->call_method('facebook.users.getLoggedInUser', array());
387    }
388  
389 <  
390 <  /**
391 <   * Returns whether or not the user corresponding to the current session object has the app installed
392 <   * @return boolean
389 >
390 >  /**
391 >   * Returns whether or not the user corresponding to the current session object has the app installed
392 >   * @return boolean
393     */
394    public function users_isAppAdded() {
395      if (isset($this->added)) {
# Line 375 | Line 400 | function toggleDisplay(id, type) {
400  
401    /**
402     * Sets the FBML for the profile of the user attached to this session
403 <   * @param   string   $markup     The FBML that describes the profile presence of this app for the user
403 >   * @param   string   $markup           The FBML that describes the profile presence of this app for the user
404 >   * @param   int      $uid              The user
405 >   * @param   string   $profile          Profile FBML
406 >   * @param   string   $profile_action   Profile action FBML
407 >   * @param   string   $mobile_profile   Mobile profile FBML
408     * @return  array    A list of strings describing any compile errors for the submitted FBML
409     */
410 <  public function profile_setFBML($markup, $uid = null) {
411 <    return $this->call_method('facebook.profile.setFBML', array('markup' => $markup, 'uid' => $uid));
410 >  function profile_setFBML($markup, $uid = null, $profile='', $profile_action='', $mobile_profile='') {
411 >    return $this->call_method('facebook.profile.setFBML', array('markup' => $markup,
412 >                                                                'uid' => $uid,
413 >                                                                'profile' => $profile,
414 >                                                                'profile_action' => $profile_action,
415 >                                                                'mobile_profile' => $mobile_profile));
416    }
417  
418    public function profile_getFBML($uid) {
# Line 449 | Line 482 | function toggleDisplay(id, type) {
482     * @return bool       True on success
483     */
484    function marketplace_removeListing($listing_id, $status='DEFAULT') {
485 <    return $this->call_method('facebook.marketplace.removeListing',
486 <                              array('listing_id'=>$listing_id,
485 >    return $this->call_method('facebook.marketplace.removeListing',
486 >                              array('listing_id'=>$listing_id,
487                                      'status'=>$status));
488    }
489  
490    /**
491     * Create/modify a Marketplace listing for the loggedinuser
492 <   *
492 >   *
493     * @param int              listing_id   The id of a listing to be modified, 0 for a new listing.
494     * @param show_on_profile  bool         Should we show this listing on the user's profile
495 <   * @param attrs            array        An array of the listing data
495 >   * @param listing_attrs    array        An array of the listing data
496     * @return                 int          The listing_id (unchanged if modifying an existing listing)
497     */
498    function marketplace_createListing($listing_id, $show_on_profile, $attrs) {
499 <    return $this->call_method('facebook.marketplace.createListing',
500 <                              array('listing_id'=>$listing_id,
501 <                                    'show_on_profile'=>$show_on_profile,
502 <                                    'attrs'=>json_encode($attrs)));
499 >    return $this->call_method('facebook.marketplace.createListing',
500 >                              array('listing_id'=>$listing_id,
501 >                                    'show_on_profile'=>$show_on_profile,
502 >                                    'listing_attrs'=>json_encode($attrs)));
503    }
504  
505  
506    /////////////////////////////////////////////////////////////////////////////
507    // Data Store API
508 <  
508 >
509    /**
510     * Set a user preference.
511     *
# Line 495 | Line 528 | function toggleDisplay(id, type) {
528     * Set a user's all preferences for this application.
529     *
530     * @param  values     preferece values in an associative arrays
531 <   * @param  replace    whether to replace all existing preferences or
531 >   * @param  replace    whether to replace all existing preferences or
532     *                    merge into them.
533     * @error
534     *    API_EC_DATA_DATABASE_ERROR
# Line 617 | Line 650 | function toggleDisplay(id, type) {
650     *    API_EC_DATA_QUOTA_EXCEEDED
651     *    API_EC_DATA_UNKNOWN_ERROR
652     */
653 <  public function data_defineObjectProperty($obj_type, $prop_name, $prop_type){
653 >  public function data_defineObjectProperty($obj_type, $prop_name, $prop_type) {
654      return $this->call_method
655        ('facebook.data.defineObjectProperty',
656         array('obj_type' => $obj_type,
# Line 627 | Line 660 | function toggleDisplay(id, type) {
660  
661    /**
662     * Remove a previously defined property from an object type.
663 <   *
663 >   *
664     * @param  obj_type      object type's name
665     * @param  prop_name     name of the property to remove
666     * @error
# Line 648 | Line 681 | function toggleDisplay(id, type) {
681  
682    /**
683     * Rename a previously defined property of an object type.
684 <   *
684 >   *
685     * @param  obj_type      object type's name
686     * @param  prop_name     name of the property to rename
687     * @param  new_name      new name to use
# Line 708 | Line 741 | function toggleDisplay(id, type) {
741  
742    /**
743     * Create a new object.
744 <   *
744 >   *
745     * @param  obj_type      object type's name
746     * @param  properties    (optional) properties to set initially
747     * @return               newly created object's id
# Line 879 | Line 912 | function toggleDisplay(id, type) {
912  
913    /**
914     * Read hash value by key.
915 <   *
915 >   *
916     * @param  obj_type      object type's name
917     * @param  key           hash key
918     * @param  prop_name     (optional) individual property's name
# Line 902 | Line 935 | function toggleDisplay(id, type) {
935  
936    /**
937     * Write hash value by key.
938 <   *
938 >   *
939     * @param  obj_type      object type's name
940     * @param  key           hash key
941     * @param  value         hash value
# Line 926 | Line 959 | function toggleDisplay(id, type) {
959  
960    /**
961     * Increase a hash value by specified increment atomically.
962 <   *
962 >   *
963     * @param  obj_type      object type's name
964     * @param  key           hash key
965     * @param  prop_name     individual property's name
# Line 1017 | Line 1050 | function toggleDisplay(id, type) {
1050               'assoc_info2' => json_encode($assoc_info2),
1051               'inverse' => $inverse));
1052    }
1053 <  
1053 >
1054    /**
1055     * Undefine an object association.
1056     *
# Line 1063 | Line 1096 | function toggleDisplay(id, type) {
1096               'new_alias1' => $new_alias1,
1097               'new_alias2' => $new_alias2));
1098    }
1099 <  
1099 >
1100    /**
1101     * Get definition of an object association.
1102     *
# Line 1082 | Line 1115 | function toggleDisplay(id, type) {
1115        ('facebook.data.getAssociationDefinition',
1116         array('name' => $name));
1117    }
1118 <  
1118 >
1119    /**
1120     * Get definition of all associations.
1121     *
# Line 1101 | Line 1134 | function toggleDisplay(id, type) {
1134  
1135    /**
1136     * Create or modify an association between two objects.
1137 <   *
1137 >   *
1138     * @param  name        name of association
1139     * @param  obj_id1     id of first object
1140     * @param  obj_id2     id of second object
# Line 1128 | Line 1161 | function toggleDisplay(id, type) {
1161  
1162    /**
1163     * Create or modify associations between objects.
1164 <   *
1164 >   *
1165     * @param  assocs      associations to set
1166     * @param  name        (optional) name of association
1167     * @error
# Line 1148 | Line 1181 | function toggleDisplay(id, type) {
1181  
1182    /**
1183     * Remove an association between two objects.
1184 <   *
1184 >   *
1185     * @param  name        name of association
1186     * @param  obj_id1     id of first object
1187     * @param  obj_id2     id of second object
# Line 1163 | Line 1196 | function toggleDisplay(id, type) {
1196    public function data_removeAssociation($name, $obj_id1, $obj_id2) {
1197      return $this->call_method
1198        ('facebook.data.removeAssociation',
1199 <       array('obj_id1' => $obj_id1,
1199 >       array('name' => $name,
1200 >             'obj_id1' => $obj_id1,
1201               'obj_id2' => $obj_id2));
1202    }
1203  
1204    /**
1205     * Remove associations between objects by specifying pairs of object ids.
1206 <   *
1206 >   *
1207     * @param  assocs      associations to remove
1208     * @param  name        (optional) name of association
1209     * @error
# Line 1189 | Line 1223 | function toggleDisplay(id, type) {
1223  
1224    /**
1225     * Remove associations between objects by specifying one object id.
1226 <   *
1226 >   *
1227     * @param  name        name of association
1228     * @param  obj_id      who's association to remove
1229     * @error
# Line 1227 | Line 1261 | function toggleDisplay(id, type) {
1261    public function data_getAssociatedObjects($name, $obj_id, $no_data = true) {
1262      return $this->call_method
1263        ('facebook.data.getAssociatedObjects',
1264 <       array('obj_id' => $obj_id,
1264 >       array('name' => $name,
1265 >             'obj_id' => $obj_id,
1266               'no_data' => $no_data));
1267    }
1268  
# Line 1408 | Line 1443 | function toggleDisplay(id, type) {
1443        return $arr;
1444      } else {
1445        return (string)$sxml;
1446 <    }
1446 >    }
1447    }
1448   }
1449  
# Line 1469 | Line 1504 | class FacebookAPIErrorCodes {
1504    const API_EC_DATA_OBJECT_NOT_FOUND = 803;
1505    const API_EC_DATA_OBJECT_ALREADY_EXISTS = 804;
1506    const API_EC_DATA_DATABASE_ERROR = 805;
1507 <
1507 >
1508    public static $api_error_descriptions = array(
1509        API_EC_SUCCESS           => 'Success',
1510        API_EC_UNKNOWN           => 'An unknown error occurred',
# Line 1533 | Line 1568 | $profile_field_array = array(
1568      "quotes",
1569      "relationship_status",
1570      "religion",
1571 <    "sex",
1571 >    "sex",
1572      "significant_other_id",
1573      "status",
1574      "timezone",
1575      "tv",
1576 <    "wall_count",
1576 >    "wall_count",
1577      "work_history");
1578   ?>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines