ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/facebook/trunk/facebookapi_php5_restlib.php
Revision: 1015
Committed: 2008-05-25T05:56:55-07:00 (17 years ago) by douglas
File size: 64751 byte(s)
Log Message:
Merged with 2008-04-29, grr!

File Contents

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

Properties

Name Value
svn:keywords Id