secret = $secret;
$this->session_key = $session_key;
$this->api_key = $api_key;
$this->last_call_id = 0;
$this->server_addr = Facebook::get_facebook_url('api') . '/restserver.php';
if ($GLOBALS['facebook_config']['debug']) {
$this->cur_id = 0;
?>
call_method('facebook.auth.getSession', array('auth_token'=>$auth_token));
$this->session_key = $result['session_key'];
if (isset($result['secret']) && $result['secret']) {
// desktop apps have a special secret
$this->secret = $result['secret'];
}
return $result;
}
/**
* Returns events according to the filters specified.
* @param int $uid Optional: User associated with events.
* A null parameter will default to the session user.
* @param array $eids Optional: Filter by these event ids.
* A null parameter will get all events for the user.
* @param int $start_time Optional: Filter with this UTC as lower bound.
* A null or zero parameter indicates no lower bound.
* @param int $end_time Optional: Filter with this UTC as upper bound.
* A null or zero parameter indicates no upper bound.
* @param string $rsvp_status Optional: Only show events where the given uid
* has this rsvp status. This only works if you have specified a value for
* $uid. Values are as in events.getMembers. Null indicates to ignore
* rsvp status when filtering.
* @return array of events
*/
public function events_get($uid, $eids, $start_time, $end_time, $rsvp_status) {
return $this->call_method('facebook.events.get',
array(
'uid' => $uid,
'eids' => $eids,
'start_time' => $start_time,
'end_time' => $end_time,
'rsvp_status' => $rsvp_status));
}
/**
* Returns membership list data associated with an event
* @param int $eid : event id
* @return assoc array of four membership lists, with keys 'attending',
* 'unsure', 'declined', and 'not_replied'
*/
public function events_getMembers($eid) {
return $this->call_method('facebook.events.getMembers',
array('eid' => $eid));
}
/**
* Makes an FQL query. This is a generalized way of accessing all the data
* in the API, as an alternative to most of the other method calls. More
* info at http://developers.facebook.com/documentation.php?v=1.0&doc=fql
* @param string $query the query to evaluate
* @return generalized array representing the results
*/
public function fql_query($query) {
return $this->call_method('facebook.fql.query',
array('query' => $query));
}
public function feed_publishStoryToUser($title, $body,
$image_1=null, $image_1_link=null,
$image_2=null, $image_2_link=null,
$image_3=null, $image_3_link=null,
$image_4=null, $image_4_link=null) {
return $this->call_method('facebook.feed.publishStoryToUser',
array('title' => $title,
'body' => $body,
'image_1' => $image_1,
'image_1_link' => $image_1_link,
'image_2' => $image_2,
'image_2_link' => $image_2_link,
'image_3' => $image_3,
'image_3_link' => $image_3_link,
'image_4' => $image_4,
'image_4_link' => $image_4_link));
}
public function feed_publishActionOfUser($title, $body,
$image_1=null, $image_1_link=null,
$image_2=null, $image_2_link=null,
$image_3=null, $image_3_link=null,
$image_4=null, $image_4_link=null) {
return $this->call_method('facebook.feed.publishActionOfUser',
array('title' => $title,
'body' => $body,
'image_1' => $image_1,
'image_1_link' => $image_1_link,
'image_2' => $image_2,
'image_2_link' => $image_2_link,
'image_3' => $image_3,
'image_3_link' => $image_3_link,
'image_4' => $image_4,
'image_4_link' => $image_4_link));
}
public function feed_publishTemplatizedAction($actor_id, $title_template, $title_data,
$body_template, $body_data, $body_general,
$image_1=null, $image_1_link=null,
$image_2=null, $image_2_link=null,
$image_3=null, $image_3_link=null,
$image_4=null, $image_4_link=null,
$target_ids=null) {
return $this->call_method('facebook.feed.publishTemplatizedAction',
array('actor_id' => $actor_id,
'title_template' => $title_template,
'title_data' => is_array($title_data) ? json_encode($title_data) : $title_data,
'body_template' => $body_template,
'body_data' => is_array($body_data) ? json_encode($body_data) : $body_data,
'body_general' => $body_general,
'image_1' => $image_1,
'image_1_link' => $image_1_link,
'image_2' => $image_2,
'image_2_link' => $image_2_link,
'image_3' => $image_3,
'image_3_link' => $image_3_link,
'image_4' => $image_4,
'image_4_link' => $image_4_link,
'target_ids' => $target_ids));
}
/**
* Returns whether or not pairs of users are friends.
* Note that the Facebook friend relationship is symmetric.
* @param array $uids1: array of ids (id_1, id_2,...) of some length X
* @param array $uids2: array of ids (id_A, id_B,...) of SAME length X
* @return array of uid pairs with bool, true if pair are friends, e.g.
* array( 0 => array('uid1' => id_1, 'uid2' => id_A, 'are_friends' => 1),
* 1 => array('uid1' => id_2, 'uid2' => id_B, 'are_friends' => 0)
* ...)
*/
public function friends_areFriends($uids1, $uids2) {
return $this->call_method('facebook.friends.areFriends',
array('uids1'=>$uids1, 'uids2'=>$uids2));
}
/**
* Returns the friends of the current session user.
* @return array of friends
*/
public function friends_get() {
if (isset($this->friends_list)) {
return $this->friends_list;
}
return $this->call_method('facebook.friends.get', array());
}
/**
* Returns the friends of the session user, who are also users
* of the calling application.
* @return array of friends
*/
public function friends_getAppUsers() {
return $this->call_method('facebook.friends.getAppUsers', array());
}
/**
* Returns groups according to the filters specified.
* @param int $uid Optional: User associated with groups.
* A null parameter will default to the session user.
* @param array $gids Optional: group ids to query.
* A null parameter will get all groups for the user.
* @return array of groups
*/
public function groups_get($uid, $gids) {
return $this->call_method('facebook.groups.get',
array(
'uid' => $uid,
'gids' => $gids));
}
/**
* Returns the membership list of a group
* @param int $gid : Group id
* @return assoc array of four membership lists, with keys
* 'members', 'admins', 'officers', and 'not_replied'
*/
public function groups_getMembers($gid) {
return $this->call_method('facebook.groups.getMembers',
array('gid' => $gid));
}
/**
* Returns the outstanding notifications for the session user.
* @return assoc array of
* notification count objects for 'messages', 'pokes' and 'shares',
* a uid list of 'friend_requests', a gid list of 'group_invites',
* and an eid list of 'event_invites'
*/
public function notifications_get() {
return $this->call_method('facebook.notifications.get', array());
}
/**
* Sends an email notification to the specified user.
* @return string url which you should send the logged in user to to finalize the message.
*/
public function notifications_send($to_ids, $notification, $email='') {
return $this->call_method('facebook.notifications.send',
array('to_ids' => $to_ids, 'notification' => $notification, 'email' => $email));
}
/**
* Sends a request to the specified user (e.g. "you have 1 event invitation")
* @param array $to_ids user ids to receive the request (must be friends with sender, capped at 10)
* @param string $type type of request, e.g. "event" (as in "You have an event invitation.")
* @param string $content fbml content of the request. really stripped down fbml - just
* text/names/links. also, use the special tag