[44] | 1 | <?php
|
---|
| 2 | //
|
---|
| 3 | // +---------------------------------------------------------------------------+
|
---|
| 4 | // | Facebook Platform PHP4 client |
|
---|
| 5 | // +---------------------------------------------------------------------------+
|
---|
| 6 | // | Copyright (c) 2007 Facebook, Inc. |
|
---|
| 7 | // | All rights reserved. |
|
---|
| 8 | // | |
|
---|
| 9 | // | Redistribution and use in source and binary forms, with or without |
|
---|
| 10 | // | modification, are permitted provided that the following conditions |
|
---|
| 11 | // | are met: |
|
---|
| 12 | // | |
|
---|
| 13 | // | 1. Redistributions of source code must retain the above copyright |
|
---|
| 14 | // | notice, this list of conditions and the following disclaimer. |
|
---|
| 15 | // | 2. Redistributions in binary form must reproduce the above copyright |
|
---|
| 16 | // | notice, this list of conditions and the following disclaimer in the |
|
---|
| 17 | // | documentation and/or other materials provided with the distribution. |
|
---|
| 18 | // | |
|
---|
| 19 | // | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
---|
| 20 | // | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
---|
| 21 | // | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
---|
| 22 | // | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
---|
| 23 | // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
---|
| 24 | // | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
---|
| 25 | // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
---|
| 26 | // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
---|
| 27 | // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
---|
| 28 | // | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
---|
| 29 | // +---------------------------------------------------------------------------+
|
---|
| 30 | // | For help with this library, contact developers-help@facebook.com |
|
---|
| 31 | // +---------------------------------------------------------------------------+
|
---|
| 32 | //
|
---|
| 33 | // What I've changed:
|
---|
| 34 | // PHP4 does not have json_encode so I added a JSON.php class (in classes/ directory,
|
---|
| 35 | // function which takes care of it is at the bottom of the file
|
---|
| 36 | // Facebook now fixed their problems with public's, so the only change now is I used an old xml2array function instead of simplexml
|
---|
| 37 | // because if you have a query which returns a lot of results (i.e. friends when you have about 3000 friends)
|
---|
| 38 | // simplexml will not be able to handle that and give you a timeout, old xml2array takes a few seconds for the same query
|
---|
| 39 | // of course simplexml is still availble, just uncomment the following line and the convert_simplexml_to_array function on line 1441
|
---|
| 40 | //include_once 'simplexml44-0_4_4/class/IsterXmlSimpleXMLImpl.php';
|
---|
| 41 |
|
---|
| 42 | if (!class_exists('FacebookRestClient')):
|
---|
| 43 | class FacebookRestClient {
|
---|
| 44 | var $secret;
|
---|
| 45 | var $session_key;
|
---|
| 46 | var $api_key;
|
---|
| 47 | var $facebook;
|
---|
| 48 | var $error_code;
|
---|
| 49 | var $friends_list; // to save making the friends.get api call, this will get prepopulated on canvas pages
|
---|
| 50 | var $added; // to save making the users.isAppAdded api call, this will get prepopulated on canvas pages
|
---|
| 51 |
|
---|
| 52 | /**
|
---|
| 53 | * Create the client.
|
---|
| 54 | * @param string $session_key if you haven't gotten a session key yet, leave
|
---|
| 55 | * this as null and then set it later by just
|
---|
| 56 | * directly accessing the $session_key member
|
---|
| 57 | * variable.
|
---|
| 58 | */
|
---|
| 59 | function FacebookRestClient($api_key, $secret, &$facebook, $session_key=null) {
|
---|
| 60 | $this->secret = $secret;
|
---|
| 61 | $this->session_key = $session_key;
|
---|
| 62 | $this->api_key = $api_key;
|
---|
| 63 | $this->last_call_id = 0;
|
---|
| 64 | $this->facebook = &$facebook;
|
---|
| 65 | $this->error_code = 0;
|
---|
| 66 | $this->server_addr = $this->facebook->get_facebook_url('api') . '/restserver.php';
|
---|
| 67 | if ($GLOBALS['facebook_config']['debug']) {
|
---|
| 68 | $this->cur_id = 0;
|
---|
| 69 | ?>
|
---|
| 70 | <script type="text/javascript">
|
---|
| 71 | var types = ['params', 'xml', 'php', 'sxml'];
|
---|
| 72 | function toggleDisplay(id, type) {
|
---|
| 73 | for each (var t in types) {
|
---|
| 74 | if (t != type || document.getElementById(t + id).style.display == 'block') {
|
---|
| 75 | document.getElementById(t + id).style.display = 'none';
|
---|
| 76 | } else {
|
---|
| 77 | document.getElementById(t + id).style.display = 'block';
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 | return false;
|
---|
| 81 | }
|
---|
| 82 | </script>
|
---|
| 83 | <?php
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | /**
|
---|
| 88 | * Returns the session information available after current user logs in.
|
---|
| 89 | * @param string $auth_token the token returned by auth_createToken or
|
---|
| 90 | * passed back to your callback_url.
|
---|
| 91 | * @return assoc array containing session_key, uid
|
---|
| 92 | */
|
---|
| 93 | function auth_getSession($auth_token) {
|
---|
| 94 | $result = $this->call_method('facebook.auth.getSession', array('auth_token'=>$auth_token));
|
---|
| 95 | $this->session_key = $result['session_key'];
|
---|
| 96 | if (isset($result['secret']) && $result['secret']) {
|
---|
| 97 | // desktop apps have a special secret
|
---|
| 98 | $this->secret = $result['secret'];
|
---|
| 99 | }
|
---|
| 100 | return $result;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
| 104 | * Expires the session that is currently being used. If this call is successful, no further calls to the
|
---|
| 105 | * API (which require a session) can be made until a valid session is created.
|
---|
| 106 | *
|
---|
| 107 | * @return bool true if session expiration was successful, false otherwise
|
---|
| 108 | */
|
---|
| 109 | function auth_expireSession() {
|
---|
| 110 | return $this->call_method('facebook.auth.expireSession', array());
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | /**
|
---|
| 114 | * Returns events according to the filters specified.
|
---|
| 115 | * @param int $uid Optional: User associated with events.
|
---|
| 116 | * A null parameter will default to the session user.
|
---|
| 117 | * @param array $eids Optional: Filter by these event ids.
|
---|
| 118 | * A null parameter will get all events for the user.
|
---|
| 119 | * @param int $start_time Optional: Filter with this UTC as lower bound.
|
---|
| 120 | * A null or zero parameter indicates no lower bound.
|
---|
| 121 | * @param int $end_time Optional: Filter with this UTC as upper bound.
|
---|
| 122 | * A null or zero parameter indicates no upper bound.
|
---|
| 123 | * @param string $rsvp_status Optional: Only show events where the given uid
|
---|
| 124 | * has this rsvp status. This only works if you have specified a value for
|
---|
| 125 | * $uid. Values are as in events.getMembers. Null indicates to ignore
|
---|
| 126 | * rsvp status when filtering.
|
---|
| 127 | * @return array of events
|
---|
| 128 | */
|
---|
| 129 | function events_get($uid, $eids, $start_time, $end_time, $rsvp_status) {
|
---|
| 130 | return $this->call_method('facebook.events.get',
|
---|
| 131 | array(
|
---|
| 132 | 'uid' => $uid,
|
---|
| 133 | 'eids' => $eids,
|
---|
| 134 | 'start_time' => $start_time,
|
---|
| 135 | 'end_time' => $end_time,
|
---|
| 136 | 'rsvp_status' => $rsvp_status));
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | /**
|
---|
| 140 | * Returns membership list data associated with an event
|
---|
| 141 | * @param int $eid : event id
|
---|
| 142 | * @return assoc array of four membership lists, with keys 'attending',
|
---|
| 143 | * 'unsure', 'declined', and 'not_replied'
|
---|
| 144 | */
|
---|
| 145 | function events_getMembers($eid) {
|
---|
| 146 | return $this->call_method('facebook.events.getMembers',
|
---|
| 147 | array('eid' => $eid));
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | /**
|
---|
| 151 | * Makes an FQL query. This is a generalized way of accessing all the data
|
---|
| 152 | * in the API, as an alternative to most of the other method calls. More
|
---|
| 153 | * info at http://developers.facebook.com/documentation.php?v=1.0&doc=fql
|
---|
| 154 | * @param string $query the query to evaluate
|
---|
| 155 | * @return generalized array representing the results
|
---|
| 156 | */
|
---|
| 157 | function fql_query($query) {
|
---|
| 158 | return $this->call_method('facebook.fql.query',
|
---|
| 159 | array('query' => $query));
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | function feed_publishStoryToUser($title, $body,
|
---|
| 163 | $image_1=null, $image_1_link=null,
|
---|
| 164 | $image_2=null, $image_2_link=null,
|
---|
| 165 | $image_3=null, $image_3_link=null,
|
---|
| 166 | $image_4=null, $image_4_link=null) {
|
---|
| 167 | return $this->call_method('facebook.feed.publishStoryToUser',
|
---|
| 168 | array('title' => $title,
|
---|
| 169 | 'body' => $body,
|
---|
| 170 | 'image_1' => $image_1,
|
---|
| 171 | 'image_1_link' => $image_1_link,
|
---|
| 172 | 'image_2' => $image_2,
|
---|
| 173 | 'image_2_link' => $image_2_link,
|
---|
| 174 | 'image_3' => $image_3,
|
---|
| 175 | 'image_3_link' => $image_3_link,
|
---|
| 176 | 'image_4' => $image_4,
|
---|
| 177 | 'image_4_link' => $image_4_link));
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | function feed_publishActionOfUser($title, $body,
|
---|
| 181 | $image_1=null, $image_1_link=null,
|
---|
| 182 | $image_2=null, $image_2_link=null,
|
---|
| 183 | $image_3=null, $image_3_link=null,
|
---|
| 184 | $image_4=null, $image_4_link=null) {
|
---|
| 185 | return $this->call_method('facebook.feed.publishActionOfUser',
|
---|
| 186 | array('title' => $title,
|
---|
| 187 | 'body' => $body,
|
---|
| 188 | 'image_1' => $image_1,
|
---|
| 189 | 'image_1_link' => $image_1_link,
|
---|
| 190 | 'image_2' => $image_2,
|
---|
| 191 | 'image_2_link' => $image_2_link,
|
---|
| 192 | 'image_3' => $image_3,
|
---|
| 193 | 'image_3_link' => $image_3_link,
|
---|
| 194 | 'image_4' => $image_4,
|
---|
| 195 | 'image_4_link' => $image_4_link));
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | function feed_publishTemplatizedAction($actor_id, $title_template, $title_data,
|
---|
| 199 | $body_template, $body_data, $body_general,
|
---|
| 200 | $image_1=null, $image_1_link=null,
|
---|
| 201 | $image_2=null, $image_2_link=null,
|
---|
| 202 | $image_3=null, $image_3_link=null,
|
---|
| 203 | $image_4=null, $image_4_link=null,
|
---|
| 204 | $target_ids='') {
|
---|
| 205 | return $this->call_method('facebook.feed.publishTemplatizedAction',
|
---|
| 206 | array('actor_id' => $actor_id,
|
---|
| 207 | 'title_template' => $title_template,
|
---|
| 208 | 'title_data' => $title_data,
|
---|
| 209 | 'body_template' => $body_template,
|
---|
| 210 | 'body_data' => $body_data,
|
---|
| 211 | 'body_general' => $body_general,
|
---|
| 212 | 'image_1' => $image_1,
|
---|
| 213 | 'image_1_link' => $image_1_link,
|
---|
| 214 | 'image_2' => $image_2,
|
---|
| 215 | 'image_2_link' => $image_2_link,
|
---|
| 216 | 'image_3' => $image_3,
|
---|
| 217 | 'image_3_link' => $image_3_link,
|
---|
| 218 | 'image_4' => $image_4,
|
---|
| 219 | 'image_4_link' => $image_4_link,
|
---|
| 220 | 'target_ids' => $target_ids));
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | //REYES
|
---|
| 224 | function json_encode($data){
|
---|
| 225 | require_once 'classes/JSON.php';
|
---|
| 226 | $json = new Services_JSON();
|
---|
| 227 | return $json->encode($data);
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | function feed_registerTemplateBundle($one_line_story_templates,$short_story_templates =array(),$full_story_template = null){
|
---|
| 231 |
|
---|
| 232 | $templates = array('one_line_story_templates' => $this->json_encode($one_line_story_templates));
|
---|
| 233 |
|
---|
| 234 | if (!empty($short_story_templates)) {
|
---|
| 235 | $templates['short_story_templates'] = $this->json_encode($short_story_templates);
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | if (isset($full_story_template)) {
|
---|
| 239 | $templates['full_story_template'] = $this->json_encode($full_story_template);
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | return $this->call_method('facebook.feed.registerTemplateBundle',
|
---|
| 243 | $templates);
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | function feed_getRegisteredTemplateBundles()
|
---|
| 247 | {
|
---|
| 248 | return $this->call_method('facebook.feed.getRegisteredTemplateBundles', array());
|
---|
| 249 |
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | function feed_getRegisteredTemplateBundleByID($template_bundle_id)
|
---|
| 253 | {
|
---|
| 254 | return $this->call_method('facebook.feed.getRegisteredTemplateBundleByID',
|
---|
| 255 | array('template_bundle_id' => $template_bundle_id));
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | function feed_deactivateTemplateBundleByID($template_bundle_id)
|
---|
| 259 | {
|
---|
| 260 | return $this->call_method('facebook.feed.deactivateTemplateBundleByID',
|
---|
| 261 | array('template_bundle_id' => $template_bundle_id));
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | function feed_publishUserAction($template_bundle_id, $template_data,
|
---|
| 265 | $target_ids=array(), $body_general='')
|
---|
| 266 | {
|
---|
| 267 | return $this->call_method('facebook.feed.publishUserAction',
|
---|
| 268 | array('template_bundle_id' => $template_bundle_id,
|
---|
| 269 | 'template_data' => $this->json_encode($template_data),
|
---|
| 270 | 'target_ids' => $target_ids,
|
---|
| 271 | 'body_general' => $body_general));
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 |
|
---|
| 275 |
|
---|
| 276 | /**
|
---|
| 277 | * Returns whether or not pairs of users are friends.
|
---|
| 278 | * Note that the Facebook friend relationship is symmetric.
|
---|
| 279 | * @param array $uids1: array of ids (id_1, id_2,...) of some length X
|
---|
| 280 | * @param array $uids2: array of ids (id_A, id_B,...) of SAME length X
|
---|
| 281 | * @return array of uid pairs with bool, true if pair are friends, e.g.
|
---|
| 282 | * array( 0 => array('uid1' => id_1, 'uid2' => id_A, 'are_friends' => 1),
|
---|
| 283 | * 1 => array('uid1' => id_2, 'uid2' => id_B, 'are_friends' => 0)
|
---|
| 284 | * ...)
|
---|
| 285 | */
|
---|
| 286 | function friends_areFriends($uids1, $uids2) {
|
---|
| 287 | return $this->call_method('facebook.friends.areFriends',
|
---|
| 288 | array('uids1'=>$uids1, 'uids2'=>$uids2));
|
---|
| 289 | }
|
---|
| 290 |
|
---|
| 291 | /**
|
---|
| 292 | * Returns the friends of the current session user.
|
---|
| 293 | * @return array of friends
|
---|
| 294 | */
|
---|
| 295 | function friends_get() {
|
---|
| 296 | if (isset($this->friends_list)) {
|
---|
| 297 | return $this->friends_list;
|
---|
| 298 | }
|
---|
| 299 | return $this->call_method('facebook.friends.get', array());
|
---|
| 300 | }
|
---|
| 301 |
|
---|
| 302 | /**
|
---|
| 303 | * Returns the friends of the session user, who are also users
|
---|
| 304 | * of the calling application.
|
---|
| 305 | * @return array of friends
|
---|
| 306 | */
|
---|
| 307 | function friends_getAppUsers() {
|
---|
| 308 | return $this->call_method('facebook.friends.getAppUsers', array());
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | /**
|
---|
| 312 | * Returns groups according to the filters specified.
|
---|
| 313 | * @param int $uid Optional: User associated with groups.
|
---|
| 314 | * A null parameter will default to the session user.
|
---|
| 315 | * @param array $gids Optional: group ids to query.
|
---|
| 316 | * A null parameter will get all groups for the user.
|
---|
| 317 | * @return array of groups
|
---|
| 318 | */
|
---|
| 319 | function groups_get($uid, $gids) {
|
---|
| 320 | return $this->call_method('facebook.groups.get',
|
---|
| 321 | array(
|
---|
| 322 | 'uid' => $uid,
|
---|
| 323 | 'gids' => $gids));
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | /**
|
---|
| 327 | * Returns the membership list of a group
|
---|
| 328 | * @param int $gid : Group id
|
---|
| 329 | * @return assoc array of four membership lists, with keys
|
---|
| 330 | * 'members', 'admins', 'officers', and 'not_replied'
|
---|
| 331 | */
|
---|
| 332 | function groups_getMembers($gid) {
|
---|
| 333 | return $this->call_method('facebook.groups.getMembers',
|
---|
| 334 | array('gid' => $gid));
|
---|
| 335 | }
|
---|
| 336 |
|
---|
| 337 | /**
|
---|
| 338 | * Returns the outstanding notifications for the session user.
|
---|
| 339 | * @return assoc array of
|
---|
| 340 | * notification count objects for 'messages', 'pokes' and 'shares',
|
---|
| 341 | * a uid list of 'friend_requests', a gid list of 'group_invites',
|
---|
| 342 | * and an eid list of 'event_invites'
|
---|
| 343 | */
|
---|
| 344 | function notifications_get() {
|
---|
| 345 | return $this->call_method('facebook.notifications.get', array());
|
---|
| 346 | }
|
---|
| 347 |
|
---|
| 348 | /**
|
---|
| 349 | * Sends a notification to the specified users.
|
---|
| 350 | * @return (nothing)
|
---|
| 351 | */
|
---|
| 352 | function notifications_send($to_ids, $notification) {
|
---|
| 353 | return $this->call_method('facebook.notifications.send',
|
---|
| 354 | array('to_ids' => $to_ids, 'notification' => $notification));
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | /**
|
---|
| 358 | * Sends an email to the specified user of the application.
|
---|
| 359 | * @param array $recipients : ids of the recipients
|
---|
| 360 | * @param string $subject : subject of the email
|
---|
| 361 | * @param string $text : (plain text) body of the email
|
---|
| 362 | * @param string $fbml : fbml markup if you want an html version of the email
|
---|
| 363 | * @return comma separated list of successful recipients
|
---|
| 364 | */
|
---|
| 365 | function notifications_sendEmail($recipients, $subject, $text, $fbml) {
|
---|
| 366 | return $this->call_method('facebook.notifications.sendEmail',
|
---|
| 367 | array('recipients' => $recipients,
|
---|
| 368 | 'subject' => $subject,
|
---|
| 369 | 'text' => $text,
|
---|
| 370 | 'fbml' => $fbml));
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | /**
|
---|
| 374 | * Returns the requested info fields for the requested set of pages
|
---|
| 375 | * @param array $page_ids an array of page ids
|
---|
| 376 | * @param array $fields an array of strings describing the info fields desired
|
---|
| 377 | * @param int $uid Optionally, limit results to pages of which this user is a fan.
|
---|
| 378 | * @param string type limits results to a particular type of page.
|
---|
| 379 | * @return array of pages
|
---|
| 380 | */
|
---|
| 381 | function pages_getInfo($page_ids, $fields, $uid, $type) {
|
---|
| 382 | return $this->call_method('facebook.pages.getInfo', array('page_ids' => $page_ids, 'fields' => $fields, 'uid' => $uid, 'type' => $type));
|
---|
| 383 | }
|
---|
| 384 |
|
---|
| 385 | /**
|
---|
| 386 | * Returns true if logged in user is an admin for the passed page
|
---|
| 387 | * @param int $page_id target page id
|
---|
| 388 | * @return boolean
|
---|
| 389 | */
|
---|
| 390 | function pages_isAdmin($page_id) {
|
---|
| 391 | return $this->call_method('facebook.pages.isAdmin', array('page_id' => $page_id));
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 | /**
|
---|
| 395 | * Returns whether or not the page corresponding to the current session object has the app installed
|
---|
| 396 | * @return boolean
|
---|
| 397 | */
|
---|
| 398 | function pages_isAppAdded() {
|
---|
| 399 | if (isset($this->added)) {
|
---|
| 400 | return $this->added;
|
---|
| 401 | }
|
---|
| 402 | return $this->call_method('facebook.pages.isAppAdded', array());
|
---|
| 403 | }
|
---|
| 404 |
|
---|
| 405 | /**
|
---|
| 406 | * Returns true if logged in user is a fan for the passed page
|
---|
| 407 | * @param int $page_id target page id
|
---|
| 408 | * @param int $uid user to compare. If empty, the logged in user.
|
---|
| 409 | * @return bool
|
---|
| 410 | */
|
---|
| 411 | function pages_isFan($page_id, $uid) {
|
---|
| 412 | return $this->call_method('facebook.pages.isFan', array('page_id' => $page_id, 'uid' => $uid));
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 | /**
|
---|
| 416 | * Returns photos according to the filters specified.
|
---|
| 417 | * @param int $subj_id Optional: Filter by uid of user tagged in the photos.
|
---|
| 418 | * @param int $aid Optional: Filter by an album, as returned by
|
---|
| 419 | * photos_getAlbums.
|
---|
| 420 | * @param array $pids Optional: Restrict to a list of pids
|
---|
| 421 | * Note that at least one of these parameters needs to be specified, or an
|
---|
| 422 | * error is returned.
|
---|
| 423 | * @return array of photo objects.
|
---|
| 424 | */
|
---|
| 425 | function photos_get($subj_id, $aid, $pids) {
|
---|
| 426 | return $this->call_method('facebook.photos.get',
|
---|
| 427 | array('subj_id' => $subj_id, 'aid' => $aid, 'pids' => $pids));
|
---|
| 428 | }
|
---|
| 429 |
|
---|
| 430 | /**
|
---|
| 431 | * Returns the albums created by the given user.
|
---|
| 432 | * @param int $uid Optional: the uid of the user whose albums you want.
|
---|
| 433 | * A null value will return the albums of the session user.
|
---|
| 434 | * @param array $aids Optional: a list of aids to restrict the query.
|
---|
| 435 | * Note that at least one of the (uid, aids) parameters must be specified.
|
---|
| 436 | * @returns an array of album objects.
|
---|
| 437 | */
|
---|
| 438 | function photos_getAlbums($uid, $aids) {
|
---|
| 439 | return $this->call_method('facebook.photos.getAlbums',
|
---|
| 440 | array('uid' => $uid,
|
---|
| 441 | 'aids' => $aids));
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | /**
|
---|
| 445 | * Returns the tags on all photos specified.
|
---|
| 446 | * @param string $pids : a list of pids to query
|
---|
| 447 | * @return array of photo tag objects, with include pid, subject uid,
|
---|
| 448 | * and two floating-point numbers (xcoord, ycoord) for tag pixel location
|
---|
| 449 | */
|
---|
| 450 | function photos_getTags($pids) {
|
---|
| 451 | return $this->call_method('facebook.photos.getTags',
|
---|
| 452 | array('pids' => $pids));
|
---|
| 453 | }
|
---|
| 454 |
|
---|
| 455 | /**
|
---|
| 456 | * Returns the requested info fields for the requested set of users
|
---|
| 457 | * @param array $uids an array of user ids
|
---|
| 458 | * @param array $fields an array of strings describing the info fields desired
|
---|
| 459 | * @return array of users
|
---|
| 460 | */
|
---|
| 461 | function users_getInfo($uids, $fields) {
|
---|
| 462 | return $this->call_method('facebook.users.getInfo', array('uids' => $uids, 'fields' => $fields));
|
---|
| 463 | }
|
---|
| 464 |
|
---|
| 465 | /**
|
---|
| 466 | * Returns the user corresponding to the current session object.
|
---|
| 467 | * @return integer uid
|
---|
| 468 | */
|
---|
| 469 | function users_getLoggedInUser() {
|
---|
| 470 | return $this->call_method('facebook.users.getLoggedInUser', array());
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 |
|
---|
| 474 | /**
|
---|
| 475 | * Returns whether or not the user corresponding to the current session object has the app installed
|
---|
| 476 | * @return boolean
|
---|
| 477 | */
|
---|
| 478 | function users_isAppAdded() {
|
---|
| 479 | if (isset($this->added)) {
|
---|
| 480 | return $this->added;
|
---|
| 481 | }
|
---|
| 482 | return $this->call_method('facebook.users.isAppAdded', array());
|
---|
| 483 | }
|
---|
| 484 |
|
---|
| 485 | /**
|
---|
| 486 | * Sets the FBML for the profile of the user attached to this session
|
---|
| 487 | * @param string $markup The FBML that describes the profile presence of this app for the user
|
---|
| 488 | * @param int $uid The user
|
---|
| 489 | * @param string $profile Profile FBML
|
---|
| 490 | * @param string $profile_action Profile action FBML
|
---|
| 491 | * @param string $mobile_profile Mobile profile FBML
|
---|
| 492 | * @return array A list of strings describing any compile errors for the submitted FBML
|
---|
| 493 | */
|
---|
| 494 | function profile_setFBML($markup, $uid = null, $profile='', $profile_action='', $mobile_profile='') {
|
---|
| 495 | return $this->call_method('facebook.profile.setFBML', array('markup' => $markup,
|
---|
| 496 | 'uid' => $uid,
|
---|
| 497 | 'profile' => $profile,
|
---|
| 498 | 'profile_action' => $profile_action,
|
---|
| 499 | 'mobile_profile' => $mobile_profile));
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | function profile_getFBML($uid) {
|
---|
| 503 | return $this->call_method('facebook.profile.getFBML', array('uid' => $uid));
|
---|
| 504 | }
|
---|
| 505 |
|
---|
| 506 | function fbml_refreshImgSrc($url) {
|
---|
| 507 | return $this->call_method('facebook.fbml.refreshImgSrc', array('url' => $url));
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | function fbml_refreshRefUrl($url) {
|
---|
| 511 | return $this->call_method('facebook.fbml.refreshRefUrl', array('url' => $url));
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 | function fbml_setRefHandle($handle, $fbml) {
|
---|
| 515 | return $this->call_method('facebook.fbml.setRefHandle', array('handle' => $handle, 'fbml' => $fbml));
|
---|
| 516 | }
|
---|
| 517 |
|
---|
| 518 | /**
|
---|
| 519 | * Get all the marketplace categories
|
---|
| 520 | *
|
---|
| 521 | * @return array A list of category names
|
---|
| 522 | */
|
---|
| 523 | function marketplace_getCategories() {
|
---|
| 524 | return $this->call_method('facebook.marketplace.getCategories', array());
|
---|
| 525 | }
|
---|
| 526 |
|
---|
| 527 | /**
|
---|
| 528 | * Get all the marketplace subcategories for a particular category
|
---|
| 529 | *
|
---|
| 530 | * @param category The category for which we are pulling subcategories
|
---|
| 531 | * @return array A list of subcategory names
|
---|
| 532 | */
|
---|
| 533 | function marketplace_getSubCategories($category) {
|
---|
| 534 | return $this->call_method('facebook.marketplace.getSubCategories', array('category' => $category));
|
---|
| 535 | }
|
---|
| 536 |
|
---|
| 537 | /**
|
---|
| 538 | * Get listings by either listing_id or user
|
---|
| 539 | *
|
---|
| 540 | * @param listing_ids An array of listing_ids (optional)
|
---|
| 541 | * @param uids An array of user ids (optional)
|
---|
| 542 | * @return array The data for matched listings
|
---|
| 543 | */
|
---|
| 544 | function marketplace_getListings($listing_ids, $uids) {
|
---|
| 545 | return $this->call_method('facebook.marketplace.getListings', array('listing_ids' => $listing_ids, 'uids' => $uids));
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | /**
|
---|
| 549 | * Search for Marketplace listings. All arguments are optional, though at least
|
---|
| 550 | * one must be filled out to retrieve results.
|
---|
| 551 | *
|
---|
| 552 | * @param category The category in which to search (optional)
|
---|
| 553 | * @param subcategory The subcategory in which to search (optional)
|
---|
| 554 | * @param query A query string (optional)
|
---|
| 555 | * @return array The data for matched listings
|
---|
| 556 | */
|
---|
| 557 | function marketplace_search($category, $subcategory, $query) {
|
---|
| 558 | return $this->call_method('facebook.marketplace.search', array('category' => $category, 'subcategory' => $subcategory, 'query' => $query));
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | /**
|
---|
| 562 | * Remove a listing from Marketplace
|
---|
| 563 | *
|
---|
| 564 | * @param listing_id The id of the listing to be removed
|
---|
| 565 | * @param status 'SUCCESS', 'NOT_SUCCESS', or 'DEFAULT'
|
---|
| 566 | * @return bool True on success
|
---|
| 567 | */
|
---|
| 568 | function marketplace_removeListing($listing_id, $status='DEFAULT') {
|
---|
| 569 | return $this->call_method('facebook.marketplace.removeListing',
|
---|
| 570 | array('listing_id'=>$listing_id,
|
---|
| 571 | 'status'=>$status));
|
---|
| 572 | }
|
---|
| 573 |
|
---|
| 574 | /**
|
---|
| 575 | * Create/modify a Marketplace listing for the loggedinuser
|
---|
| 576 | *
|
---|
| 577 | * @param int listing_id The id of a listing to be modified, 0 for a new listing.
|
---|
| 578 | * @param show_on_profile bool Should we show this listing on the user's profile
|
---|
| 579 | * @param attrs array An array of the listing data
|
---|
| 580 | * @return int The listing_id (unchanged if modifying an existing listing)
|
---|
| 581 | */
|
---|
| 582 | function marketplace_createListing($listing_id, $show_on_profile, $attrs) {
|
---|
| 583 | return $this->call_method('facebook.marketplace.createListing',
|
---|
| 584 | array('listing_id'=>$listing_id,
|
---|
| 585 | 'show_on_profile'=>$show_on_profile,
|
---|
| 586 | 'listing_attrs'=>json_encode($attrs)));
|
---|
| 587 | }
|
---|
| 588 |
|
---|
| 589 |
|
---|
| 590 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 591 | // Data Store API
|
---|
| 592 |
|
---|
| 593 | /**
|
---|
| 594 | * Set a user preference.
|
---|
| 595 | *
|
---|
| 596 | * @param pref_id preference identifier (0-200)
|
---|
| 597 | * @param value preferece's value
|
---|
| 598 | * @error
|
---|
| 599 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 600 | * API_EC_PARAM
|
---|
| 601 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 602 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 603 | */
|
---|
| 604 | function data_setUserPreference($pref_id, $value) {
|
---|
| 605 | return $this->call_method
|
---|
| 606 | ('facebook.data.setUserPreference',
|
---|
| 607 | array('pref_id' => $pref_id,
|
---|
| 608 | 'value' => $value));
|
---|
| 609 | }
|
---|
| 610 |
|
---|
| 611 | /**
|
---|
| 612 | * Set a user's all preferences for this application.
|
---|
| 613 | *
|
---|
| 614 | * @param values preferece values in an associative arrays
|
---|
| 615 | * @param replace whether to replace all existing preferences or
|
---|
| 616 | * merge into them.
|
---|
| 617 | * @error
|
---|
| 618 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 619 | * API_EC_PARAM
|
---|
| 620 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 621 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 622 | */
|
---|
| 623 | function data_setUserPreferences($values, $replace = false) {
|
---|
| 624 | return $this->call_method
|
---|
| 625 | ('facebook.data.setUserPreferences',
|
---|
| 626 | array('values' => json_encode($values),
|
---|
| 627 | 'replace' => $replace));
|
---|
| 628 | }
|
---|
| 629 |
|
---|
| 630 | /**
|
---|
| 631 | * Get a user preference.
|
---|
| 632 | *
|
---|
| 633 | * @param pref_id preference identifier (0-200)
|
---|
| 634 | * @return preference's value
|
---|
| 635 | * @error
|
---|
| 636 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 637 | * API_EC_PARAM
|
---|
| 638 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 639 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 640 | */
|
---|
| 641 | function data_getUserPreference($pref_id) {
|
---|
| 642 | return $this->call_method
|
---|
| 643 | ('facebook.data.getUserPreference',
|
---|
| 644 | array('pref_id' => $pref_id));
|
---|
| 645 | }
|
---|
| 646 |
|
---|
| 647 | /**
|
---|
| 648 | * Get a user preference.
|
---|
| 649 | *
|
---|
| 650 | * @return preference values
|
---|
| 651 | * @error
|
---|
| 652 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 653 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 654 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 655 | */
|
---|
| 656 | function data_getUserPreferences() {
|
---|
| 657 | return $this->call_method
|
---|
| 658 | ('facebook.data.getUserPreferences',
|
---|
| 659 | array());
|
---|
| 660 | }
|
---|
| 661 |
|
---|
| 662 | /**
|
---|
| 663 | * Create a new object type.
|
---|
| 664 | *
|
---|
| 665 | * @param name object type's name
|
---|
| 666 | * @error
|
---|
| 667 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 668 | * API_EC_DATA_OBJECT_ALREADY_EXISTS
|
---|
| 669 | * API_EC_PARAM
|
---|
| 670 | * API_EC_PERMISSION
|
---|
| 671 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 672 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 673 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 674 | */
|
---|
| 675 | function data_createObjectType($name) {
|
---|
| 676 | return $this->call_method
|
---|
| 677 | ('facebook.data.createObjectType',
|
---|
| 678 | array('name' => $name));
|
---|
| 679 | }
|
---|
| 680 |
|
---|
| 681 | /**
|
---|
| 682 | * Delete an object type.
|
---|
| 683 | *
|
---|
| 684 | * @param obj_type object type's name
|
---|
| 685 | * @error
|
---|
| 686 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 687 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 688 | * API_EC_PARAM
|
---|
| 689 | * API_EC_PERMISSION
|
---|
| 690 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 691 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 692 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 693 | */
|
---|
| 694 | function data_dropObjectType($obj_type) {
|
---|
| 695 | return $this->call_method
|
---|
| 696 | ('facebook.data.dropObjectType',
|
---|
| 697 | array('obj_type' => $obj_type));
|
---|
| 698 | }
|
---|
| 699 |
|
---|
| 700 | /**
|
---|
| 701 | * Rename an object type.
|
---|
| 702 | *
|
---|
| 703 | * @param obj_type object type's name
|
---|
| 704 | * @param new_name new object type's name
|
---|
| 705 | * @error
|
---|
| 706 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 707 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 708 | * API_EC_DATA_OBJECT_ALREADY_EXISTS
|
---|
| 709 | * API_EC_PARAM
|
---|
| 710 | * API_EC_PERMISSION
|
---|
| 711 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 712 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 713 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 714 | */
|
---|
| 715 | function data_renameObjectType($obj_type, $new_name) {
|
---|
| 716 | return $this->call_method
|
---|
| 717 | ('facebook.data.renameObjectType',
|
---|
| 718 | array('obj_type' => $obj_type,
|
---|
| 719 | 'new_name' => $new_name));
|
---|
| 720 | }
|
---|
| 721 |
|
---|
| 722 | /**
|
---|
| 723 | * Add a new property to an object type.
|
---|
| 724 | *
|
---|
| 725 | * @param obj_type object type's name
|
---|
| 726 | * @param prop_name name of the property to add
|
---|
| 727 | * @param prop_type 1: integer; 2: string; 3: text blob
|
---|
| 728 | * @error
|
---|
| 729 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 730 | * API_EC_DATA_OBJECT_ALREADY_EXISTS
|
---|
| 731 | * API_EC_PARAM
|
---|
| 732 | * API_EC_PERMISSION
|
---|
| 733 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 734 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 735 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 736 | */
|
---|
| 737 | function data_defineObjectProperty($obj_type, $prop_name, $prop_type) {
|
---|
| 738 | return $this->call_method
|
---|
| 739 | ('facebook.data.defineObjectProperty',
|
---|
| 740 | array('obj_type' => $obj_type,
|
---|
| 741 | 'prop_name' => $prop_name,
|
---|
| 742 | 'prop_type' => $prop_type));
|
---|
| 743 | }
|
---|
| 744 |
|
---|
| 745 | /**
|
---|
| 746 | * Remove a previously defined property from an object type.
|
---|
| 747 | *
|
---|
| 748 | * @param obj_type object type's name
|
---|
| 749 | * @param prop_name name of the property to remove
|
---|
| 750 | * @error
|
---|
| 751 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 752 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 753 | * API_EC_PARAM
|
---|
| 754 | * API_EC_PERMISSION
|
---|
| 755 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 756 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 757 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 758 | */
|
---|
| 759 | function data_undefineObjectProperty($obj_type, $prop_name) {
|
---|
| 760 | return $this->call_method
|
---|
| 761 | ('facebook.data.undefineObjectProperty',
|
---|
| 762 | array('obj_type' => $obj_type,
|
---|
| 763 | 'prop_name' => $prop_name));
|
---|
| 764 | }
|
---|
| 765 |
|
---|
| 766 | /**
|
---|
| 767 | * Rename a previously defined property of an object type.
|
---|
| 768 | *
|
---|
| 769 | * @param obj_type object type's name
|
---|
| 770 | * @param prop_name name of the property to rename
|
---|
| 771 | * @param new_name new name to use
|
---|
| 772 | * @error
|
---|
| 773 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 774 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 775 | * API_EC_DATA_OBJECT_ALREADY_EXISTS
|
---|
| 776 | * API_EC_PARAM
|
---|
| 777 | * API_EC_PERMISSION
|
---|
| 778 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 779 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 780 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 781 | */
|
---|
| 782 | function data_renameObjectProperty($obj_type, $prop_name, $new_name) {
|
---|
| 783 | return $this->call_method
|
---|
| 784 | ('facebook.data.renameObjectProperty',
|
---|
| 785 | array('obj_type' => $obj_type,
|
---|
| 786 | 'prop_name' => $prop_name,
|
---|
| 787 | 'new_name' => $new_name));
|
---|
| 788 | }
|
---|
| 789 |
|
---|
| 790 | /**
|
---|
| 791 | * Retrieve a list of all object types that have defined for the application.
|
---|
| 792 | *
|
---|
| 793 | * @return a list of object type names
|
---|
| 794 | * @error
|
---|
| 795 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 796 | * API_EC_PERMISSION
|
---|
| 797 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 798 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 799 | */
|
---|
| 800 | function data_getObjectTypes() {
|
---|
| 801 | return $this->call_method
|
---|
| 802 | ('facebook.data.getObjectTypes',
|
---|
| 803 | array());
|
---|
| 804 | }
|
---|
| 805 |
|
---|
| 806 | /**
|
---|
| 807 | * Get definitions of all properties of an object type.
|
---|
| 808 | *
|
---|
| 809 | * @param obj_type object type's name
|
---|
| 810 | * @return pairs of property name and property types
|
---|
| 811 | * @error
|
---|
| 812 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 813 | * API_EC_PARAM
|
---|
| 814 | * API_EC_PERMISSION
|
---|
| 815 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 816 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 817 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 818 | */
|
---|
| 819 | function data_getObjectType($obj_type) {
|
---|
| 820 | return $this->call_method
|
---|
| 821 | ('facebook.data.getObjectType',
|
---|
| 822 | array('obj_type' => $obj_type));
|
---|
| 823 | }
|
---|
| 824 |
|
---|
| 825 | /**
|
---|
| 826 | * Create a new object.
|
---|
| 827 | *
|
---|
| 828 | * @param obj_type object type's name
|
---|
| 829 | * @param properties (optional) properties to set initially
|
---|
| 830 | * @return newly created object's id
|
---|
| 831 | * @error
|
---|
| 832 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 833 | * API_EC_PARAM
|
---|
| 834 | * API_EC_PERMISSION
|
---|
| 835 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 836 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 837 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 838 | */
|
---|
| 839 | function data_createObject($obj_type, $properties = null) {
|
---|
| 840 | return $this->call_method
|
---|
| 841 | ('facebook.data.createObject',
|
---|
| 842 | array('obj_type' => $obj_type,
|
---|
| 843 | 'properties' => json_encode($properties)));
|
---|
| 844 | }
|
---|
| 845 |
|
---|
| 846 | /**
|
---|
| 847 | * Update an existing object.
|
---|
| 848 | *
|
---|
| 849 | * @param obj_id object's id
|
---|
| 850 | * @param properties new properties
|
---|
| 851 | * @param replace true for replacing existing properties; false for merging
|
---|
| 852 | * @error
|
---|
| 853 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 854 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 855 | * API_EC_PARAM
|
---|
| 856 | * API_EC_PERMISSION
|
---|
| 857 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 858 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 859 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 860 | */
|
---|
| 861 | function data_updateObject($obj_id, $properties, $replace = false) {
|
---|
| 862 | return $this->call_method
|
---|
| 863 | ('facebook.data.updateObject',
|
---|
| 864 | array('obj_id' => $obj_id,
|
---|
| 865 | 'properties' => json_encode($properties),
|
---|
| 866 | 'replace' => $replace));
|
---|
| 867 | }
|
---|
| 868 |
|
---|
| 869 | /**
|
---|
| 870 | * Delete an existing object.
|
---|
| 871 | *
|
---|
| 872 | * @param obj_id object's id
|
---|
| 873 | * @error
|
---|
| 874 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 875 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 876 | * API_EC_PARAM
|
---|
| 877 | * API_EC_PERMISSION
|
---|
| 878 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 879 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 880 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 881 | */
|
---|
| 882 | function data_deleteObject($obj_id) {
|
---|
| 883 | return $this->call_method
|
---|
| 884 | ('facebook.data.deleteObject',
|
---|
| 885 | array('obj_id' => $obj_id));
|
---|
| 886 | }
|
---|
| 887 |
|
---|
| 888 | /**
|
---|
| 889 | * Delete a list of objects.
|
---|
| 890 | *
|
---|
| 891 | * @param obj_ids objects to delete
|
---|
| 892 | * @error
|
---|
| 893 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 894 | * API_EC_PARAM
|
---|
| 895 | * API_EC_PERMISSION
|
---|
| 896 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 897 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 898 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 899 | */
|
---|
| 900 | function data_deleteObjects($obj_ids) {
|
---|
| 901 | return $this->call_method
|
---|
| 902 | ('facebook.data.deleteObjects',
|
---|
| 903 | array('obj_ids' => json_encode($obj_ids)));
|
---|
| 904 | }
|
---|
| 905 |
|
---|
| 906 | /**
|
---|
| 907 | * Get a single property value of an object.
|
---|
| 908 | *
|
---|
| 909 | * @param obj_id object's id
|
---|
| 910 | * @param prop_name individual property's name
|
---|
| 911 | * @return individual property's value
|
---|
| 912 | * @error
|
---|
| 913 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 914 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 915 | * API_EC_PARAM
|
---|
| 916 | * API_EC_PERMISSION
|
---|
| 917 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 918 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 919 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 920 | */
|
---|
| 921 | function data_getObjectProperty($obj_id, $prop_name) {
|
---|
| 922 | return $this->call_method
|
---|
| 923 | ('facebook.data.getObjectProperty',
|
---|
| 924 | array('obj_id' => $obj_id,
|
---|
| 925 | 'prop_name' => $prop_name));
|
---|
| 926 | }
|
---|
| 927 |
|
---|
| 928 | /**
|
---|
| 929 | * Get properties of an object.
|
---|
| 930 | *
|
---|
| 931 | * @param obj_id object's id
|
---|
| 932 | * @param prop_names (optional) properties to return; null for all.
|
---|
| 933 | * @return specified properties of an object
|
---|
| 934 |
|
---|
| 935 | * @error
|
---|
| 936 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 937 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 938 | * API_EC_PARAM
|
---|
| 939 | * API_EC_PERMISSION
|
---|
| 940 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 941 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 942 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 943 | */
|
---|
| 944 | function data_getObject($obj_id, $prop_names = null) {
|
---|
| 945 | return $this->call_method
|
---|
| 946 | ('facebook.data.getObject',
|
---|
| 947 | array('obj_id' => $obj_id,
|
---|
| 948 | 'prop_names' => json_encode($prop_names)));
|
---|
| 949 | }
|
---|
| 950 |
|
---|
| 951 | /**
|
---|
| 952 | * Get properties of a list of objects.
|
---|
| 953 | *
|
---|
| 954 | * @param obj_ids object ids
|
---|
| 955 | * @param prop_names (optional) properties to return; null for all.
|
---|
| 956 | * @return specified properties of an object
|
---|
| 957 | * @error
|
---|
| 958 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 959 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 960 | * API_EC_PARAM
|
---|
| 961 | * API_EC_PERMISSION
|
---|
| 962 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 963 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 964 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 965 | */
|
---|
| 966 | function data_getObjects($obj_ids, $prop_names = null) {
|
---|
| 967 | return $this->call_method
|
---|
| 968 | ('facebook.data.getObjects',
|
---|
| 969 | array('obj_ids' => json_encode($obj_ids),
|
---|
| 970 | 'prop_names' => json_encode($prop_names)));
|
---|
| 971 | }
|
---|
| 972 |
|
---|
| 973 | /**
|
---|
| 974 | * Set a single property value of an object.
|
---|
| 975 | *
|
---|
| 976 | * @param obj_id object's id
|
---|
| 977 | * @param prop_name individual property's name
|
---|
| 978 | * @param prop_value new value to set
|
---|
| 979 | * @error
|
---|
| 980 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 981 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 982 | * API_EC_PARAM
|
---|
| 983 | * API_EC_PERMISSION
|
---|
| 984 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 985 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 986 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 987 | */
|
---|
| 988 | function data_setObjectProperty($obj_id, $prop_name, $prop_value) {
|
---|
| 989 | return $this->call_method
|
---|
| 990 | ('facebook.data.setObjectProperty',
|
---|
| 991 | array('obj_id' => $obj_id,
|
---|
| 992 | 'prop_name' => $prop_name,
|
---|
| 993 | 'prop_value' => $prop_value));
|
---|
| 994 | }
|
---|
| 995 |
|
---|
| 996 | /**
|
---|
| 997 | * Read hash value by key.
|
---|
| 998 | *
|
---|
| 999 | * @param obj_type object type's name
|
---|
| 1000 | * @param key hash key
|
---|
| 1001 | * @param prop_name (optional) individual property's name
|
---|
| 1002 | * @return hash value
|
---|
| 1003 | * @error
|
---|
| 1004 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1005 | * API_EC_PARAM
|
---|
| 1006 | * API_EC_PERMISSION
|
---|
| 1007 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1008 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1009 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1010 | */
|
---|
| 1011 | function data_getHashValue($obj_type, $key, $prop_name = null) {
|
---|
| 1012 | return $this->call_method
|
---|
| 1013 | ('facebook.data.getHashValue',
|
---|
| 1014 | array('obj_type' => $obj_type,
|
---|
| 1015 | 'key' => $key,
|
---|
| 1016 | 'prop_name' => $prop_name));
|
---|
| 1017 | }
|
---|
| 1018 |
|
---|
| 1019 | /**
|
---|
| 1020 | * Write hash value by key.
|
---|
| 1021 | *
|
---|
| 1022 | * @param obj_type object type's name
|
---|
| 1023 | * @param key hash key
|
---|
| 1024 | * @param value hash value
|
---|
| 1025 | * @param prop_name (optional) individual property's name
|
---|
| 1026 | * @error
|
---|
| 1027 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1028 | * API_EC_PARAM
|
---|
| 1029 | * API_EC_PERMISSION
|
---|
| 1030 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1031 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1032 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1033 | */
|
---|
| 1034 | function data_setHashValue($obj_type, $key, $value, $prop_name = null) {
|
---|
| 1035 | return $this->call_method
|
---|
| 1036 | ('facebook.data.setHashValue',
|
---|
| 1037 | array('obj_type' => $obj_type,
|
---|
| 1038 | 'key' => $key,
|
---|
| 1039 | 'value' => $value,
|
---|
| 1040 | 'prop_name' => $prop_name));
|
---|
| 1041 | }
|
---|
| 1042 |
|
---|
| 1043 | /**
|
---|
| 1044 | * Increase a hash value by specified increment atomically.
|
---|
| 1045 | *
|
---|
| 1046 | * @param obj_type object type's name
|
---|
| 1047 | * @param key hash key
|
---|
| 1048 | * @param prop_name individual property's name
|
---|
| 1049 | * @param increment (optional) default is 1
|
---|
| 1050 | * @return incremented hash value
|
---|
| 1051 | * @error
|
---|
| 1052 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1053 | * API_EC_PARAM
|
---|
| 1054 | * API_EC_PERMISSION
|
---|
| 1055 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1056 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1057 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1058 | */
|
---|
| 1059 | function data_incHashValue($obj_type, $key, $prop_name, $increment = 1) {
|
---|
| 1060 | return $this->call_method
|
---|
| 1061 | ('facebook.data.incHashValue',
|
---|
| 1062 | array('obj_type' => $obj_type,
|
---|
| 1063 | 'key' => $key,
|
---|
| 1064 | 'prop_name' => $prop_name,
|
---|
| 1065 | 'increment' => $increment));
|
---|
| 1066 | }
|
---|
| 1067 |
|
---|
| 1068 | /**
|
---|
| 1069 | * Remove a hash key and its values.
|
---|
| 1070 | *
|
---|
| 1071 | * @param obj_type object type's name
|
---|
| 1072 | * @param key hash key
|
---|
| 1073 | * @error
|
---|
| 1074 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1075 | * API_EC_PARAM
|
---|
| 1076 | * API_EC_PERMISSION
|
---|
| 1077 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1078 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1079 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1080 | */
|
---|
| 1081 | function data_removeHashKey($obj_type, $key) {
|
---|
| 1082 | return $this->call_method
|
---|
| 1083 | ('facebook.data.removeHashKey',
|
---|
| 1084 | array('obj_type' => $obj_type,
|
---|
| 1085 | 'key' => $key));
|
---|
| 1086 | }
|
---|
| 1087 |
|
---|
| 1088 | /**
|
---|
| 1089 | * Remove hash keys and their values.
|
---|
| 1090 | *
|
---|
| 1091 | * @param obj_type object type's name
|
---|
| 1092 | * @param keys hash keys
|
---|
| 1093 | * @error
|
---|
| 1094 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1095 | * API_EC_PARAM
|
---|
| 1096 | * API_EC_PERMISSION
|
---|
| 1097 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1098 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1099 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1100 | */
|
---|
| 1101 | function data_removeHashKeys($obj_type, $keys) {
|
---|
| 1102 | return $this->call_method
|
---|
| 1103 | ('facebook.data.removeHashKeys',
|
---|
| 1104 | array('obj_type' => $obj_type,
|
---|
| 1105 | 'keys' => json_encode($keys)));
|
---|
| 1106 | }
|
---|
| 1107 |
|
---|
| 1108 |
|
---|
| 1109 | /**
|
---|
| 1110 | * Define an object association.
|
---|
| 1111 | *
|
---|
| 1112 | * @param name name of this association
|
---|
| 1113 | * @param assoc_type 1: one-way 2: two-way symmetric 3: two-way asymmetric
|
---|
| 1114 | * @param assoc_info1 needed info about first object type
|
---|
| 1115 | * @param assoc_info2 needed info about second object type
|
---|
| 1116 | * @param inverse (optional) name of reverse association
|
---|
| 1117 | * @error
|
---|
| 1118 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1119 | * API_EC_DATA_OBJECT_ALREADY_EXISTS
|
---|
| 1120 | * API_EC_PARAM
|
---|
| 1121 | * API_EC_PERMISSION
|
---|
| 1122 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1123 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1124 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1125 | */
|
---|
| 1126 | function data_defineAssociation($name, $assoc_type, $assoc_info1,
|
---|
| 1127 | $assoc_info2, $inverse = null) {
|
---|
| 1128 | return $this->call_method
|
---|
| 1129 | ('facebook.data.defineAssociation',
|
---|
| 1130 | array('name' => $name,
|
---|
| 1131 | 'assoc_type' => $assoc_type,
|
---|
| 1132 | 'assoc_info1' => json_encode($assoc_info1),
|
---|
| 1133 | 'assoc_info2' => json_encode($assoc_info2),
|
---|
| 1134 | 'inverse' => $inverse));
|
---|
| 1135 | }
|
---|
| 1136 |
|
---|
| 1137 | /**
|
---|
| 1138 | * Undefine an object association.
|
---|
| 1139 | *
|
---|
| 1140 | * @param name name of this association
|
---|
| 1141 | * @error
|
---|
| 1142 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1143 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1144 | * API_EC_PARAM
|
---|
| 1145 | * API_EC_PERMISSION
|
---|
| 1146 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1147 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1148 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1149 | */
|
---|
| 1150 | function data_undefineAssociation($name) {
|
---|
| 1151 | return $this->call_method
|
---|
| 1152 | ('facebook.data.undefineAssociation',
|
---|
| 1153 | array('name' => $name));
|
---|
| 1154 | }
|
---|
| 1155 |
|
---|
| 1156 | /**
|
---|
| 1157 | * Rename an object association or aliases.
|
---|
| 1158 | *
|
---|
| 1159 | * @param name name of this association
|
---|
| 1160 | * @param new_name (optional) new name of this association
|
---|
| 1161 | * @param new_alias1 (optional) new alias for object type 1
|
---|
| 1162 | * @param new_alias2 (optional) new alias for object type 2
|
---|
| 1163 | * @error
|
---|
| 1164 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1165 | * API_EC_DATA_OBJECT_ALREADY_EXISTS
|
---|
| 1166 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1167 | * API_EC_PARAM
|
---|
| 1168 | * API_EC_PERMISSION
|
---|
| 1169 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1170 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1171 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1172 | */
|
---|
| 1173 | function data_renameAssociation($name, $new_name, $new_alias1 = null,
|
---|
| 1174 | $new_alias2 = null) {
|
---|
| 1175 | return $this->call_method
|
---|
| 1176 | ('facebook.data.renameAssociation',
|
---|
| 1177 | array('name' => $name,
|
---|
| 1178 | 'new_name' => $new_name,
|
---|
| 1179 | 'new_alias1' => $new_alias1,
|
---|
| 1180 | 'new_alias2' => $new_alias2));
|
---|
| 1181 | }
|
---|
| 1182 |
|
---|
| 1183 | /**
|
---|
| 1184 | * Get definition of an object association.
|
---|
| 1185 | *
|
---|
| 1186 | * @param name name of this association
|
---|
| 1187 | * @return specified association
|
---|
| 1188 | * @error
|
---|
| 1189 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1190 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1191 | * API_EC_PARAM
|
---|
| 1192 | * API_EC_PERMISSION
|
---|
| 1193 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1194 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1195 | */
|
---|
| 1196 | function data_getAssociationDefinition($name) {
|
---|
| 1197 | return $this->call_method
|
---|
| 1198 | ('facebook.data.getAssociationDefinition',
|
---|
| 1199 | array('name' => $name));
|
---|
| 1200 | }
|
---|
| 1201 |
|
---|
| 1202 | /**
|
---|
| 1203 | * Get definition of all associations.
|
---|
| 1204 | *
|
---|
| 1205 | * @return all defined associations
|
---|
| 1206 | * @error
|
---|
| 1207 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1208 | * API_EC_PERMISSION
|
---|
| 1209 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1210 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1211 | */
|
---|
| 1212 | function data_getAssociationDefinitions() {
|
---|
| 1213 | return $this->call_method
|
---|
| 1214 | ('facebook.data.getAssociationDefinitions',
|
---|
| 1215 | array());
|
---|
| 1216 | }
|
---|
| 1217 |
|
---|
| 1218 | /**
|
---|
| 1219 | * Create or modify an association between two objects.
|
---|
| 1220 | *
|
---|
| 1221 | * @param name name of association
|
---|
| 1222 | * @param obj_id1 id of first object
|
---|
| 1223 | * @param obj_id2 id of second object
|
---|
| 1224 | * @param data (optional) extra string data to store
|
---|
| 1225 | * @param assoc_time (optional) extra time data; default to creation time
|
---|
| 1226 | * @error
|
---|
| 1227 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1228 | * API_EC_PARAM
|
---|
| 1229 | * API_EC_PERMISSION
|
---|
| 1230 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1231 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1232 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1233 | */
|
---|
| 1234 | function data_setAssociation($name, $obj_id1, $obj_id2, $data = null,
|
---|
| 1235 | $assoc_time = null) {
|
---|
| 1236 | return $this->call_method
|
---|
| 1237 | ('facebook.data.setAssociation',
|
---|
| 1238 | array('name' => $name,
|
---|
| 1239 | 'obj_id1' => $obj_id1,
|
---|
| 1240 | 'obj_id2' => $obj_id2,
|
---|
| 1241 | 'data' => $data,
|
---|
| 1242 | 'assoc_time' => $assoc_time));
|
---|
| 1243 | }
|
---|
| 1244 |
|
---|
| 1245 | /**
|
---|
| 1246 | * Create or modify associations between objects.
|
---|
| 1247 | *
|
---|
| 1248 | * @param assocs associations to set
|
---|
| 1249 | * @param name (optional) name of association
|
---|
| 1250 | * @error
|
---|
| 1251 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1252 | * API_EC_PARAM
|
---|
| 1253 | * API_EC_PERMISSION
|
---|
| 1254 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1255 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1256 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1257 | */
|
---|
| 1258 | function data_setAssociations($assocs, $name = null) {
|
---|
| 1259 | return $this->call_method
|
---|
| 1260 | ('facebook.data.setAssociations',
|
---|
| 1261 | array('assocs' => json_encode($assocs),
|
---|
| 1262 | 'name' => $name));
|
---|
| 1263 | }
|
---|
| 1264 |
|
---|
| 1265 | /**
|
---|
| 1266 | * Remove an association between two objects.
|
---|
| 1267 | *
|
---|
| 1268 | * @param name name of association
|
---|
| 1269 | * @param obj_id1 id of first object
|
---|
| 1270 | * @param obj_id2 id of second object
|
---|
| 1271 | * @error
|
---|
| 1272 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1273 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1274 | * API_EC_PARAM
|
---|
| 1275 | * API_EC_PERMISSION
|
---|
| 1276 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1277 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1278 | */
|
---|
| 1279 | function data_removeAssociation($name, $obj_id1, $obj_id2) {
|
---|
| 1280 | return $this->call_method
|
---|
| 1281 | ('facebook.data.removeAssociation',
|
---|
| 1282 | array('name' => $name,
|
---|
| 1283 | 'obj_id1' => $obj_id1,
|
---|
| 1284 | 'obj_id2' => $obj_id2));
|
---|
| 1285 | }
|
---|
| 1286 |
|
---|
| 1287 | /**
|
---|
| 1288 | * Remove associations between objects by specifying pairs of object ids.
|
---|
| 1289 | *
|
---|
| 1290 | * @param assocs associations to remove
|
---|
| 1291 | * @param name (optional) name of association
|
---|
| 1292 | * @error
|
---|
| 1293 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1294 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1295 | * API_EC_PARAM
|
---|
| 1296 | * API_EC_PERMISSION
|
---|
| 1297 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1298 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1299 | */
|
---|
| 1300 | function data_removeAssociations($assocs, $name = null) {
|
---|
| 1301 | return $this->call_method
|
---|
| 1302 | ('facebook.data.removeAssociations',
|
---|
| 1303 | array('assocs' => json_encode($assocs),
|
---|
| 1304 | 'name' => $name));
|
---|
| 1305 | }
|
---|
| 1306 |
|
---|
| 1307 | /**
|
---|
| 1308 | * Remove associations between objects by specifying one object id.
|
---|
| 1309 | *
|
---|
| 1310 | * @param name name of association
|
---|
| 1311 | * @param obj_id who's association to remove
|
---|
| 1312 | * @error
|
---|
| 1313 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1314 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1315 | * API_EC_PARAM
|
---|
| 1316 | * API_EC_PERMISSION
|
---|
| 1317 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1318 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1319 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1320 | */
|
---|
| 1321 | function data_removeAssociatedObjects($name, $obj_id) {
|
---|
| 1322 | return $this->call_method
|
---|
| 1323 | ('facebook.data.removeAssociatedObjects',
|
---|
| 1324 | array('name' => $name,
|
---|
| 1325 | 'obj_id' => $obj_id));
|
---|
| 1326 | }
|
---|
| 1327 |
|
---|
| 1328 | /**
|
---|
| 1329 | * Retrieve a list of associated objects.
|
---|
| 1330 | *
|
---|
| 1331 | * @param name name of association
|
---|
| 1332 | * @param obj_id who's association to retrieve
|
---|
| 1333 | * @param no_data only return object ids
|
---|
| 1334 | * @return associated objects
|
---|
| 1335 | * @error
|
---|
| 1336 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1337 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1338 | * API_EC_PARAM
|
---|
| 1339 | * API_EC_PERMISSION
|
---|
| 1340 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1341 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1342 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1343 | */
|
---|
| 1344 | function data_getAssociatedObjects($name, $obj_id, $no_data = true) {
|
---|
| 1345 | return $this->call_method
|
---|
| 1346 | ('facebook.data.getAssociatedObjects',
|
---|
| 1347 | array('name' => $name,
|
---|
| 1348 | 'obj_id' => $obj_id,
|
---|
| 1349 | 'no_data' => $no_data));
|
---|
| 1350 | }
|
---|
| 1351 |
|
---|
| 1352 | /**
|
---|
| 1353 | * Count associated objects.
|
---|
| 1354 | *
|
---|
| 1355 | * @param name name of association
|
---|
| 1356 | * @param obj_id who's association to retrieve
|
---|
| 1357 | * @return associated object's count
|
---|
| 1358 | * @error
|
---|
| 1359 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1360 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1361 | * API_EC_PARAM
|
---|
| 1362 | * API_EC_PERMISSION
|
---|
| 1363 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1364 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1365 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1366 | */
|
---|
| 1367 | function data_getAssociatedObjectCount($name, $obj_id) {
|
---|
| 1368 | return $this->call_method
|
---|
| 1369 | ('facebook.data.getAssociatedObjectCount',
|
---|
| 1370 | array('name' => $name,
|
---|
| 1371 | 'obj_id' => $obj_id));
|
---|
| 1372 | }
|
---|
| 1373 |
|
---|
| 1374 | /**
|
---|
| 1375 | * Get a list of associated object counts.
|
---|
| 1376 | *
|
---|
| 1377 | * @param name name of association
|
---|
| 1378 | * @param obj_ids whose association to retrieve
|
---|
| 1379 | * @return associated object counts
|
---|
| 1380 | * @error
|
---|
| 1381 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1382 | * API_EC_DATA_OBJECT_NOT_FOUND
|
---|
| 1383 | * API_EC_PARAM
|
---|
| 1384 | * API_EC_PERMISSION
|
---|
| 1385 | * API_EC_DATA_INVALID_OPERATION
|
---|
| 1386 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1387 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1388 | */
|
---|
| 1389 | function data_getAssociatedObjectCounts($name, $obj_ids) {
|
---|
| 1390 | return $this->call_method
|
---|
| 1391 | ('facebook.data.getAssociatedObjectCounts',
|
---|
| 1392 | array('name' => $name,
|
---|
| 1393 | 'obj_ids' => json_encode($obj_ids)));
|
---|
| 1394 | }
|
---|
| 1395 |
|
---|
| 1396 | /**
|
---|
| 1397 | * Find all associations between two objects.
|
---|
| 1398 | *
|
---|
| 1399 | * @param obj_id1 id of first object
|
---|
| 1400 | * @param obj_id2 id of second object
|
---|
| 1401 | * @param no_data only return association names without data
|
---|
| 1402 | * @return all associations between objects
|
---|
| 1403 | * @error
|
---|
| 1404 | * API_EC_DATA_DATABASE_ERROR
|
---|
| 1405 | * API_EC_PARAM
|
---|
| 1406 | * API_EC_PERMISSION
|
---|
| 1407 | * API_EC_DATA_QUOTA_EXCEEDED
|
---|
| 1408 | * API_EC_DATA_UNKNOWN_ERROR
|
---|
| 1409 | */
|
---|
| 1410 | function data_getAssociations($obj_id1, $obj_id2, $no_data = true) {
|
---|
| 1411 | return $this->call_method
|
---|
| 1412 | ('facebook.data.getAssociations',
|
---|
| 1413 | array('obj_id1' => $obj_id1,
|
---|
| 1414 | 'obj_id2' => $obj_id2,
|
---|
| 1415 | 'no_data' => $no_data));
|
---|
| 1416 | }
|
---|
| 1417 |
|
---|
| 1418 | /* UTILITY FUNCTIONS */
|
---|
| 1419 |
|
---|
| 1420 | function call_method($method, $params) {
|
---|
| 1421 | $this->error_code = 0;
|
---|
| 1422 | $xml = $this->post_request($method, $params);
|
---|
| 1423 |
|
---|
| 1424 | /*
|
---|
| 1425 | $impl = new IsterXmlSimpleXMLImpl();
|
---|
| 1426 | $sxml = $impl->load_string($xml);
|
---|
| 1427 | $result = array();
|
---|
| 1428 | $children = $sxml->children();
|
---|
| 1429 | $result = $this->convert_simplexml_to_array($children[0]);
|
---|
| 1430 | */
|
---|
| 1431 | $result = $this->xml2array($xml);
|
---|
| 1432 |
|
---|
| 1433 | if ($GLOBALS['facebook_config']['debug']) {
|
---|
| 1434 | // output the raw xml and its corresponding php object, for debugging:
|
---|
| 1435 | print '<div style="margin: 10px 30px; padding: 5px; border: 2px solid black; background: gray; color: white; font-size: 12px; font-weight: bold;">';
|
---|
| 1436 | $this->cur_id++;
|
---|
| 1437 | print $this->cur_id . ': Called ' . $method . ', show ' .
|
---|
| 1438 | '<a href=# onclick="return toggleDisplay(' . $this->cur_id . ', \'params\');">Params</a> | '.
|
---|
| 1439 | '<a href=# onclick="return toggleDisplay(' . $this->cur_id . ', \'xml\');">XML</a> | '.
|
---|
| 1440 | '<a href=# onclick="return toggleDisplay(' . $this->cur_id . ', \'php\');">PHP</a>';
|
---|
| 1441 | print '<pre id="params'.$this->cur_id.'" style="display: none; overflow: auto;">'.print_r($params, true).'</pre>';
|
---|
| 1442 | print '<pre id="xml'.$this->cur_id.'" style="display: none; overflow: auto;">'.htmlspecialchars($xml).'</pre>';
|
---|
| 1443 | print '<pre id="php'.$this->cur_id.'" style="display: none; overflow: auto;">'.print_r($result, true).'</pre>';
|
---|
| 1444 | print '</div>';
|
---|
| 1445 | }
|
---|
| 1446 | if (is_array($result) && isset($result['error_code'])) {
|
---|
| 1447 | $this->error_code = $result['error_code'];
|
---|
| 1448 | return null;
|
---|
| 1449 | }
|
---|
| 1450 | return $result;
|
---|
| 1451 | }
|
---|
| 1452 |
|
---|
| 1453 | function post_request($method, $params) {
|
---|
| 1454 | $params['method'] = $method;
|
---|
| 1455 | $params['session_key'] = $this->session_key;
|
---|
| 1456 | $params['api_key'] = $this->api_key;
|
---|
| 1457 | $params['call_id'] = fb_microtime_float(true);
|
---|
| 1458 | if ($params['call_id'] <= $this->last_call_id) {
|
---|
| 1459 | $params['call_id'] = $this->last_call_id + 0.001;
|
---|
| 1460 | }
|
---|
| 1461 | $this->last_call_id = $params['call_id'];
|
---|
| 1462 | if (!isset($params['v'])) {
|
---|
| 1463 | $params['v'] = '1.0';
|
---|
| 1464 | }
|
---|
| 1465 | $post_params = array();
|
---|
| 1466 | foreach ($params as $key => $val) {
|
---|
| 1467 | if (is_array($val)) $params[$key] = implode(',', $val);
|
---|
| 1468 | $post_params[] = $key.'='.urlencode($params[$key]);
|
---|
| 1469 | }
|
---|
| 1470 | $secret = $this->secret;
|
---|
| 1471 | $post_params[] = 'sig='.$this->facebook->generate_sig($params, $secret);
|
---|
| 1472 | $post_string = implode('&', $post_params);
|
---|
| 1473 |
|
---|
| 1474 | if (function_exists('curl_init')) {
|
---|
| 1475 | // Use CURL if installed...
|
---|
| 1476 | $ch = curl_init();
|
---|
| 1477 | curl_setopt($ch, CURLOPT_URL, $this->server_addr);
|
---|
| 1478 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
|
---|
| 1479 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
---|
| 1480 | curl_setopt($ch, CURLOPT_USERAGENT, 'Facebook API PHP4 Client 1.1 (curl) ' . phpversion());
|
---|
| 1481 | $result = curl_exec($ch);
|
---|
| 1482 | curl_close($ch);
|
---|
| 1483 | } else {
|
---|
| 1484 | // Non-CURL based version...
|
---|
| 1485 | $context =
|
---|
| 1486 | array('http' =>
|
---|
| 1487 | array('method' => 'POST',
|
---|
| 1488 | 'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n".
|
---|
| 1489 | 'User-Agent: Facebook API PHP4 Client 1.1 (non-curl) '.phpversion()."\r\n".
|
---|
| 1490 | 'Content-length: ' . strlen($post_string),
|
---|
| 1491 | 'content' => $post_string));
|
---|
| 1492 | $contextid=stream_context_create($context);
|
---|
| 1493 | $sock=fopen($this->server_addr, 'r', false, $contextid);
|
---|
| 1494 | if ($sock) {
|
---|
| 1495 | $result='';
|
---|
| 1496 | while (!feof($sock))
|
---|
| 1497 | $result.=fgets($sock, 4096);
|
---|
| 1498 |
|
---|
| 1499 | fclose($sock);
|
---|
| 1500 | }
|
---|
| 1501 | }
|
---|
| 1502 | return $result;
|
---|
| 1503 | }
|
---|
| 1504 |
|
---|
| 1505 | /*
|
---|
| 1506 | function convert_simplexml_to_array($sxml) {
|
---|
| 1507 | if ($sxml) {
|
---|
| 1508 | $arr = array();
|
---|
| 1509 | $attrs = $sxml->attributes();
|
---|
| 1510 | foreach ($sxml->children() as $child) {
|
---|
| 1511 | if (!empty($attrs['list'])) {
|
---|
| 1512 | $arr[] = $this->convert_simplexml_to_array($child);
|
---|
| 1513 | } else {
|
---|
| 1514 | $arr[$child->___n] = $this->convert_simplexml_to_array($child);
|
---|
| 1515 | }
|
---|
| 1516 | }
|
---|
| 1517 | if (sizeof($arr) > 0) {
|
---|
| 1518 | return $arr;
|
---|
| 1519 | } else {
|
---|
| 1520 | return (string)$sxml->CDATA();
|
---|
| 1521 | }
|
---|
| 1522 | } else {
|
---|
| 1523 | return '';
|
---|
| 1524 | }
|
---|
| 1525 | }
|
---|
| 1526 | */
|
---|
| 1527 |
|
---|
| 1528 | //xml2array script from http://www.bin-co.com/php/scripts/xml2array
|
---|
| 1529 | //you still need xml_parser_create function to parse xml in PHP4
|
---|
| 1530 | function xml2array($contents) {
|
---|
| 1531 | if(!$contents) return array();
|
---|
| 1532 | if(!function_exists('xml_parser_create')) {
|
---|
| 1533 | return array();
|
---|
| 1534 | }
|
---|
| 1535 | $parser = xml_parser_create();
|
---|
| 1536 | xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
|
---|
| 1537 | xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
|
---|
| 1538 | xml_parse_into_struct( $parser, $contents, $xml_values );
|
---|
| 1539 | xml_parser_free( $parser );
|
---|
| 1540 | if(!$xml_values) return;
|
---|
| 1541 | $xml_array = array();
|
---|
| 1542 | $parents = array();
|
---|
| 1543 | $opened_tags = array();
|
---|
| 1544 | $arr = array();
|
---|
| 1545 | $current = &$xml_array;
|
---|
| 1546 | foreach($xml_values as $data) {
|
---|
| 1547 | unset($attributes,$value);
|
---|
| 1548 | extract($data);
|
---|
| 1549 | $result = '';
|
---|
| 1550 | if(isset($value)) {
|
---|
| 1551 | $result = $value;
|
---|
| 1552 | }
|
---|
| 1553 | if($type == "open") {
|
---|
| 1554 | $parent[$level-1] = &$current;
|
---|
| 1555 | if(!is_array($current) or (!in_array($tag, array_keys($current)))) {
|
---|
| 1556 | $current[$tag] = $result;
|
---|
| 1557 | $current = &$current[$tag];
|
---|
| 1558 | } else {
|
---|
| 1559 | if(isset($current[$tag][0])) {
|
---|
| 1560 | array_push($current[$tag], $result);
|
---|
| 1561 | } else {
|
---|
| 1562 | $current[$tag] = array($current[$tag],$result);
|
---|
| 1563 | }
|
---|
| 1564 | $last = count($current[$tag]) - 1;
|
---|
| 1565 | $current = &$current[$tag][$last];
|
---|
| 1566 | }
|
---|
| 1567 | } elseif($type == "complete") {
|
---|
| 1568 | if(!isset($current[$tag])) {
|
---|
| 1569 | $current[$tag] = $result;
|
---|
| 1570 | } else {
|
---|
| 1571 | if((is_array($current[$tag]) and $get_attributes == 0)
|
---|
| 1572 | or (isset($current[$tag][0]) and is_array($current[$tag][0]) and $get_attributes == 1)) {
|
---|
| 1573 | array_push($current[$tag],$result);
|
---|
| 1574 | } else {
|
---|
| 1575 | $current[$tag] = array($current[$tag],$result);
|
---|
| 1576 | }
|
---|
| 1577 | }
|
---|
| 1578 | } elseif($type == 'close') {
|
---|
| 1579 | $current = &$parent[$level-1];
|
---|
| 1580 | }
|
---|
| 1581 | }
|
---|
| 1582 | return($xml_array);
|
---|
| 1583 | }
|
---|
| 1584 | }
|
---|
| 1585 |
|
---|
| 1586 | // Supporting methods and values------
|
---|
| 1587 |
|
---|
| 1588 | /**
|
---|
| 1589 | * Error codes and descriptions for the Facebook API.
|
---|
| 1590 | */
|
---|
| 1591 |
|
---|
| 1592 | class FacebookAPIErrorCodes {
|
---|
| 1593 |
|
---|
| 1594 | var $API_EC_SUCCESS = 0;
|
---|
| 1595 |
|
---|
| 1596 | /*
|
---|
| 1597 | * GENERAL ERRORS
|
---|
| 1598 | */
|
---|
| 1599 | var $API_EC_UNKNOWN = 1;
|
---|
| 1600 | var $API_EC_SERVICE = 2;
|
---|
| 1601 | var $API_EC_METHOD = 3;
|
---|
| 1602 | var $API_EC_TOO_MANY_CALLS = 4;
|
---|
| 1603 | var $API_EC_BAD_IP = 5;
|
---|
| 1604 |
|
---|
| 1605 | /*
|
---|
| 1606 | * PARAMETER ERRORS
|
---|
| 1607 | */
|
---|
| 1608 | var $API_EC_PARAM = 100;
|
---|
| 1609 | var $API_EC_PARAM_API_KEY = 101;
|
---|
| 1610 | var $API_EC_PARAM_SESSION_KEY = 102;
|
---|
| 1611 | var $API_EC_PARAM_CALL_ID = 103;
|
---|
| 1612 | var $API_EC_PARAM_SIGNATURE = 104;
|
---|
| 1613 | var $API_EC_PARAM_USER_ID = 110;
|
---|
| 1614 | var $API_EC_PARAM_USER_FIELD = 111;
|
---|
| 1615 | var $API_EC_PARAM_SOCIAL_FIELD = 112;
|
---|
| 1616 | var $API_EC_PARAM_ALBUM_ID = 120;
|
---|
| 1617 |
|
---|
| 1618 | /*
|
---|
| 1619 | * USER PERMISSIONS ERRORS
|
---|
| 1620 | */
|
---|
| 1621 | var $API_EC_PERMISSION = 200;
|
---|
| 1622 | var $API_EC_PERMISSION_USER = 210;
|
---|
| 1623 | var $API_EC_PERMISSION_ALBUM = 220;
|
---|
| 1624 | var $API_EC_PERMISSION_PHOTO = 221;
|
---|
| 1625 |
|
---|
| 1626 | var $FQL_EC_PARSER = 601;
|
---|
| 1627 | var $FQL_EC_UNKNOWN_FIELD = 602;
|
---|
| 1628 | var $FQL_EC_UNKNOWN_TABLE = 603;
|
---|
| 1629 | var $FQL_EC_NOT_INDEXABLE = 604;
|
---|
| 1630 | var $FQL_EC_UNKNOWN_FUNCTION = 605;
|
---|
| 1631 | var $FQL_EC_INVALID_PARAM = 606;
|
---|
| 1632 |
|
---|
| 1633 | /**
|
---|
| 1634 | * DATA STORE API ERRORS
|
---|
| 1635 | */
|
---|
| 1636 | var $API_EC_DATA_UNKNOWN_ERROR = 800;
|
---|
| 1637 | var $API_EC_DATA_INVALID_OPERATION = 801;
|
---|
| 1638 | var $API_EC_DATA_QUOTA_EXCEEDED = 802;
|
---|
| 1639 | var $API_EC_DATA_OBJECT_NOT_FOUND = 803;
|
---|
| 1640 | var $API_EC_DATA_OBJECT_ALREADY_EXISTS = 804;
|
---|
| 1641 | var $API_EC_DATA_DATABASE_ERROR = 805;
|
---|
| 1642 |
|
---|
| 1643 | var $api_error_descriptions = array();
|
---|
| 1644 |
|
---|
| 1645 | function FacebookApiErrorCodes() {
|
---|
| 1646 | $this->api_error_descriptions = array(
|
---|
| 1647 | $this->API_EC_SUCCESS => 'Success',
|
---|
| 1648 | $this->API_EC_UNKNOWN => 'An unknown error occurred',
|
---|
| 1649 | $this->API_EC_SERVICE => 'Service temporarily unavailable',
|
---|
| 1650 | $this->API_EC_METHOD => 'Unknown method',
|
---|
| 1651 | $this->API_EC_TOO_MANY_CALLS => 'Application request limit reached',
|
---|
| 1652 | $this->API_EC_BAD_IP => 'Unauthorized source IP address',
|
---|
| 1653 | $this->API_EC_PARAM => 'Invalid parameter',
|
---|
| 1654 | $this->API_EC_PARAM_API_KEY => 'Invalid API key',
|
---|
| 1655 | $this->API_EC_PARAM_SESSION_KEY => 'Session key invalid or no longer valid',
|
---|
| 1656 | $this->API_EC_PARAM_CALL_ID => 'Call_id must be greater than previous',
|
---|
| 1657 | $this->API_EC_PARAM_SIGNATURE => 'Incorrect signature',
|
---|
| 1658 | $this->API_EC_PARAM_USER_ID => 'Invalid user id',
|
---|
| 1659 | $this->API_EC_PARAM_USER_FIELD => 'Invalid user info field',
|
---|
| 1660 | $this->API_EC_PARAM_SOCIAL_FIELD => 'Invalid user field',
|
---|
| 1661 | $this->API_EC_PARAM_ALBUM_ID => 'Invalid album id',
|
---|
| 1662 | $this->API_EC_PERMISSION => 'Permissions error',
|
---|
| 1663 | $this->API_EC_PERMISSION_USER => 'User not visible',
|
---|
| 1664 | $this->API_EC_PERMISSION_ALBUM => 'Album not visible',
|
---|
| 1665 | $this->API_EC_PERMISSION_PHOTO => 'Photo not visible',
|
---|
| 1666 | $this->FQL_EC_PARSER => 'FQL: Parser Error',
|
---|
| 1667 | $this->FQL_EC_UNKNOWN_FIELD => 'FQL: Unknown Field',
|
---|
| 1668 | $this->FQL_EC_UNKNOWN_TABLE => 'FQL: Unknown Table',
|
---|
| 1669 | $this->FQL_EC_NOT_INDEXABLE => 'FQL: Statement not indexable',
|
---|
| 1670 | $this->FQL_EC_UNKNOWN_FUNCTION => 'FQL: Attempted to call unknown function',
|
---|
| 1671 | $this->FQL_EC_INVALID_PARAM => 'FQL: Invalid parameter passed in',
|
---|
| 1672 | $this->API_EC_DATA_UNKNOWN_ERROR => 'Unknown data store API error',
|
---|
| 1673 | $this->API_EC_DATA_INVALID_OPERATION => 'Invalid operation',
|
---|
| 1674 | $this->API_EC_DATA_QUOTA_EXCEEDED => 'Data store allowable quota was exceeded',
|
---|
| 1675 | $this->API_EC_DATA_OBJECT_NOT_FOUND => 'Specified object cannot be found',
|
---|
| 1676 | $this->API_EC_DATA_OBJECT_ALREADY_EXISTS => 'Specified object already exists',
|
---|
| 1677 | $this->API_EC_DATA_DATABASE_ERROR => 'A database error occurred. Please try again',
|
---|
| 1678 | );
|
---|
| 1679 | }
|
---|
| 1680 | }
|
---|
| 1681 |
|
---|
| 1682 | $profile_field_array = array(
|
---|
| 1683 | "about_me",
|
---|
| 1684 | "activities",
|
---|
| 1685 | "affiliations",
|
---|
| 1686 | "birthday",
|
---|
| 1687 | "books",
|
---|
| 1688 | "current_location",
|
---|
| 1689 | "education_history",
|
---|
| 1690 | "first_name",
|
---|
| 1691 | "hometown_location",
|
---|
| 1692 | "hs_info",
|
---|
| 1693 | "interests",
|
---|
| 1694 | "is_app_user",
|
---|
| 1695 | "last_name",
|
---|
| 1696 | "meeting_for",
|
---|
| 1697 | "meeting_sex",
|
---|
| 1698 | "movies",
|
---|
| 1699 | "music",
|
---|
| 1700 | "name",
|
---|
| 1701 | "notes_count",
|
---|
| 1702 | "pic",
|
---|
| 1703 | "pic_big",
|
---|
| 1704 | "pic_small",
|
---|
| 1705 | "political",
|
---|
| 1706 | "profile_update_time",
|
---|
| 1707 | "quotes",
|
---|
| 1708 | "relationship_status",
|
---|
| 1709 | "religion",
|
---|
| 1710 | "sex",
|
---|
| 1711 | "significant_other_id",
|
---|
| 1712 | "status",
|
---|
| 1713 | "timezone",
|
---|
| 1714 | "tv",
|
---|
| 1715 | "wall_count",
|
---|
| 1716 | "work_history");
|
---|
| 1717 |
|
---|
| 1718 | function fb_microtime_float() {
|
---|
| 1719 | list($usec, $sec) = explode(' ', microtime());
|
---|
| 1720 | return ((float)$usec + (float)$sec);
|
---|
| 1721 | }
|
---|
| 1722 | endif;
|
---|
| 1723 | ?> |
---|