/**
* The application's API Key
*
- * @var stirng
+ * @var string
*/
protected $_apiKey;
* from an auth_token. Useful if client code wants to
* handle this.
* </pre>
- * @param session_key
*/
public function __construct($api_key, $secret, $context)
{
/**
- * TODO: Probably abstract out a Base class for these?
- * @return unknown_type
+ * Const'r
+ *
+ * @param Horde_Service_Facebook $facebook
+ * @param Horde_Service_Facebook_Request $request
+ * @param array $params
*/
public function __construct($facebook, $request, $params = array())
{
/**
* Return a valid FB login URL with necessary GET parameters appended.
*
- * @return string
+ * @param string $next URL to return to
+ *
+ * @return string The Facebook Login Url
*/
public function getLoginUrl($next)
{
*
* @param string $perm An EXTEND_PERMS_* constant
* @param string $success_url URL to redirect to on success
- * @param strint $cancel_url URL to redirect to on cancel
+ * @param string $cancel_url URL to redirect to on cancel
*
* @return string
*/
* Validates that a given set of parameters match their signature.
* Parameters all match a given input prefix, such as "fb_sig".
*
- * @param array $fb_params An array of all Facebook-sent parameters, not
- * including the signature itself.
- * @param $expected_sig The expected result to check against.
+ * @param array $fb_params An array of all Facebook-sent parameters, not
+ * including the signature itself.
+ * @param string $expected_sig The expected result to check against.
*
* @return boolean
*/
*
* @return string Hash to be checked against the FB provided signature.
*/
- public static function generateSignature($params_array, $secret)
+ public static function generateSignature($params, $secret)
{
$str = '';
- ksort($params_array);
- foreach ($params_array as $k => $v) {
+ ksort($params);
+ foreach ($params as $k => $v) {
$str .= "$k=$v";
}
$str .= $secret;
/**
* Set session cookies.
*
- * @param string $user FB userid
- * @param string $session_key The current session key
+ * @param string $user FB userid
+ * @param string $sessionKey The current session key
* @param timestamp $expires
*
* @return void
/**
* Set the current session user in the object and in a cookie.
*
- * @param string $user The FB userid
- * @param string $sessionKey
- * @param timestamp $expires
+ * @param string $user The FB userid
+ * @param string $sessionKey The current sessionkey
+ * @param timestamp $expires Expire time
+ * @param boolean $noCookie If true, do not set a user cookie.
*
* @return void
*/
- public function setUser($user, $sessionKey, $expires = null, $no_cookie = false)
+ public function setUser($user, $sessionKey, $expires = null, $noCookie = false)
{
- if (!$no_cookie && (!$this->_request->getCookie($this->_facebook->apiKey . '_user') ||
+ if (!$noCookie && (!$this->_request->getCookie($this->_facebook->apiKey . '_user') ||
$this->_request->getCookie($this->_facebook->apiKey . '_user') != $user)) {
$this->setCookies($user, $sessionKey, $expires);
/**
* Revoke a previously authorizied extended permission
*
- * @param $perm
- * @param $uid
+ * @param string $perm The extended permission to remove.
+ * @param string $uid The FB userid to remove permission from
+ *
* @return unknown_type
*/
public function revokeExtendedPermission($perm, $uid)
protected $_sessionKey;
/**
- *
- * @param $facebook
- * @param $request
- * @param $params
- * @return unknown_type
+ * @param Horde_Service_Facebook $facebook
+ * @param Horde_Service_Facebook_Request $request
+ * @param array $params
*/
public function __construct($facebook, $request, $params = array())
{
/**
* Horde_Service_Facebook_BatchRequest::
*
+ * Copyright 2009 The Horde Project (http://www.horde.org)
*
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @package Horde_Service_Facebook
*/
class Horde_Service_Facebook_BatchRequest extends Horde_Service_Facebook_Request
{
const BATCH_MODE_SERIAL_ONLY = 2;
/**
- *
- *
- * @param $facebook
- * @param $http_client
- * @param $params
- * @return unknown_type
+ * @param Horde_Service_Facebook $facebook
+ * @param Horde_Http_Client $http_client
+ * @param array $params
*/
public function __construct($facebook, $http_client, $params = array())
{
/**
* Add a method call to the queue
*
- * @param $method
- * @param $params
- * @return unknown_type
+ * @param $method
+ * @param $params
+ * @return unknown_type Returns a reference to the results that will be
+ * produced when the batch is run. This reference
+ * should be saved until after the batch is run and
+ * the results can be examined.
*/
public function &add($method, $params)
{
<?php
/**
* Error codes and descriptions for the Facebook API.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @package Horde_Service_Facebook
*/
class Horde_Service_Facebook_ErrorCodes {
/**
* Returns events according to the filters specified.
*
- * @param int $uid (Optional) User associated with events. A null
+ * @param integer $uid (Optional) User associated with events. A null
* parameter will default to the session user.
* @param string $eids (Optional) Filter by these comma-separated event
* ids. A null parameter will get all events for
* the user.
- * @param int $start_time (Optional) Filter with this unix time as lower
+ * @param integer $start_time (Optional) Filter with this unix time as lower
* bound. A null or zero parameter indicates no
* lower bound.
- * @param int $end_time (Optional) Filter with this UTC as upper bound.
+ * @param integer $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
/**
* Returns membership list data associated with an event.
*
- * @param int $eid event id
+ * @param integer $eid event id
*
* @return array An assoc array of four membership lists, with keys
* 'attending', 'unsure', 'declined', and 'not_replied'
/**
* RSVPs the current user to this event.
*
- * @param int $eid event id
- * @param string $rsvp_status 'attending', 'unsure', or 'declined'
+ * @param integer $eid event id
+ * @param string $rsvp_status 'attending', 'unsure', or 'declined'
*
- * @return bool true if successful
+ * @return boolean
*/
public function &rsvp($eid, $rsvp_status)
{
/**
* Cancels an event. Only works for events where application is the admin.
*
- * @param int $eid event id
+ * @param integer $eid event id
* @param string $cancel_message (Optional) message to send to members of
* the event about why it is cancelled
*
- * @return bool true if successful
+ * @return boolean
*/
public function &cancel($eid, $cancel_message = '')
{
* Creates an event on behalf of the user is there is a session, otherwise on
* behalf of app. Successful creation guarantees app will be admin.
*
- * @param assoc array $event_info json encoded event information
+ * @param array $event_info json encoded event information
*
- * @return int event id
+ * @return integer event id
*/
public function &create($event_info)
{
/**
* Edits an existing event. Only works for events where application is admin.
*
- * @param int $eid event id
- * @param assoc array $event_info json encoded event information
+ * @param integer $eid event id
+ * @param array $event_info json encoded event information
*
- * @return bool true if successful
+ * @return boolean true if successful
*/
public function &edit($eid, $event_info)
{
<?php
+/*
+ * Copyright 2009 The Horde Project (http://www.horde.org)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @package Horde_Service_Facebook
+ */
class Horde_Service_Facebook_Exception extends Exception {
}
?>
\ No newline at end of file
<?php
/**
* Feed methods
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @package Horde_Service_Facebook
*/
class Horde_Service_Facebook_Feeds extends Horde_Service_Facebook_Base
/**
* Deactivates a previously registered template bundle.
*
- * @param string $template_bundle_id The template bundle id
+ * @param string $id The template bundle id
*
- * @return bool true on success
+ * @return boolean
*/
public function &deactivateTemplateBundleByID($id)
{
*
* http://wiki.developers.facebook.com/index.php/Feed.publishUserAction
*
- * @param int $bundleId A template bundle id previously registered
+ * @param integer $bundleId A template bundle id previously registered
* @param array $data See wiki article for syntax
* @param array $targetIds (Optional) An array of friend uids of the user
* who shared in this action.
* @param string $body (Optional) Additional markup that extends
* the body of a short story.
- * @param int $size (Optional) A story size (see above)
+ * @param self::STORY_SIZE $size (Optional) A story size (see above)
*
- * @return bool true on success
+ * @return boolean
*/
public function &publishUserAction($bundleId, $data, $targetIds = '',
$body = '', $size = self::STORY_SIZE_ONE_LINE)
/**
* Returns the friends of the current session user.
*
- * @param int $flid (Optional) Only return friends on this friend list.
- * @param int $uid (Optional) Return friends for this user.
+ * @param integer $flid (Optional) Only return friends on this friend list.
+ * @param integer $uid (Optional) Return friends for this user.
*
* @return array An array of friends
*/
/**
* 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 string $gids (Optional) Comma-separated group ids to query. A null
- * parameter will get all groups for the user.
+ * @param integer $uid (Optional) User associated with groups. A null
+ * parameter will default to the session user.
+ * @param string $gids (Optional) Comma-separated group ids to query. A null
+ * parameter will get all groups for the user.
*
* @return array An array of group objects
*/
/**
* Returns the membership list of a group.
*
- * @param int $gid Group id
+ * @param integer $gid Group id
*
* @return array An array with four membership lists, with keys 'members',
* 'admins', 'officers', and 'not_replied'
/**
* Retrieves links posted by the given user.
*
- * @param int $uid The user whose links you wish to retrieve
- * @param int $limit The maximimum number of links to retrieve
- * @param array $link_ids (Optional) Array of specific link
- * IDs to retrieve by this user
+ * @param integer $uid The user whose links you wish to retrieve
+ * @param integer $limit The maximimum number of links to retrieve
+ * @param array $link_ids (Optional) Array of specific link
+ * IDs to retrieve by this user
*
* @return array An array of links.
*/
/**
* Posts a link on Facebook.
*
- * @param string $url URL/link you wish to post
- * @param string $comment (Optional) A comment about this link
- * @param int $uid (Optional) User ID that is posting this link;
- * defaults to current session user
+ * @param string $url URL/link you wish to post
+ * @param string $comment (Optional) A comment about this link
+ * @param integer $uid (Optional) User ID that is posting this link;
+ * defaults to current session user
*
- * @return bool
+ * @return boolean
*/
public function &post($url, $comment = '', $uid = null)
{
/**
* Creates a note with the specified title and content.
*
- * @param string $title Title of the note.
- * @param string $content Content of the note.
- * @param int $uid (Optional) The user for whom you are creating a
- * note; defaults to current session user
+ * @param string $title Title of the note.
+ * @param string $content Content of the note.
+ * @param integer $uid The user for whom you are creating a note;
+ * defaults to current session user
*
- * @return int The ID of the note that was just created.
+ * @return integer The ID of the note that was just created.
*/
public function &create($title, $content, $uid = null)
{
/**
* Deletes the specified note.
*
- * @param int $note_id ID of the note you wish to delete
- * @param int $uid (Optional) Owner of the note you wish to delete;
- * defaults to current session user
+ * @param integer $note_id ID of the note you wish to delete
+ * @param integer $uid Owner of the note you wish to delete;
+ * defaults to current session user
*
- * @return bool
+ * @return boolean
*/
public function &delete($note_id, $uid = null)
{
* Edits a note, replacing its title and contents with the title
* and contents specified.
*
- * @param int $note_id ID of the note you wish to edit
- * @param string $title Replacement title for the note
- * @param string $content Replacement content for the note
+ * @param integer $note_id ID of the note you wish to edit
+ * @param string $title Replacement title for the note
+ * @param string $content Replacement content for the note
*
- * @return bool
+ * @return boolean
*/
public function &edit($note_id, $title, $content)
{
* Retrieves all notes by a user. If note_ids are specified,
* retrieves only those specific notes by that user.
*
- * @param int $uid User whose notes you wish to retrieve
- * @param array $note_ids (Optional) List of specific note
- * IDs by this user to retrieve
+ * @param integer $uid User whose notes you wish to retrieve
+ * @param array $note_ids (Optional) List of specific note
+ * IDs by this user to retrieve
*
* @return array A list of all of the given user's notes, or an empty list
* if the viewer lacks permissions or if there are no visible
* @param string $type Either 'user_to_user' or 'app_to_user'
*
* @throws Horde_Service_Facebook_Exception
- * @return A comma separated list of successful recipients
+ *
+ * @return string A comma separated list of successful recipients
*/
public function &send($to_ids, $notification, $type)
{
*
* http://wiki.developers.facebook.com/index.php/Photos.addTag
*
- * @param int $pid The ID of the photo to be tagged
- * @param int $tag_uid The ID of the user being tagged. You must specify
+ * @param integer $pid The ID of the photo to be tagged
+ * @param integer $tag_uid The ID of the user being tagged. You must specify
* either the $tag_uid or the $tag_text parameter
* (unless $tags is specified).
* @param string $tag_text Some text identifying the person being tagged.
* can contain the tag_uid, tag_text, x, and y
* parameters defined above. If specified, the
* individual arguments are ignored.
- * @param int $owner_uid (Optional) The user ID of the user whose photo
- * you are tagging. If this parameter is not
- * specified, then it defaults to the session user.
+ * @param integer $owner_uid (Optional) The user ID of the user whose photo
+ * you are tagging. If this parameter is not
+ * specified, then it defaults to the session user.
*
- * @return bool true on success
+ * @return boolean
*/
public function &addTag($pid, $tag_uid, $tag_text, $x, $y, $tags, $uid = 0)
{
* @param string $visible (Optional) A privacy setting for the album.
* One of 'friends', 'friends-of-friends',
* 'networks', or 'everyone'. Default 'everyone'.
- * @param int $uid (Optional) User id for creating the album; if
+ * @param integer $uid (Optional) User id for creating the album; if
* not specified, the session user is used.
*
* @return array An album object
/**
* Returns photos according to the filters specified.
*
- * @param int $subj_id (Optional) Filter by uid of user tagged in the photos.
- * @param int $aid (Optional) Filter by an album, as returned by
- * photos_getAlbums.
- * @param string $pids (Optional) Restrict to a comma-separated list of pids
- *
* Note that at least one of these parameters needs to be specified, or an
* error is returned.
*
+ * @param integer $subj_id (Optional) Filter by uid of user tagged in the photos.
+ * @param integer $aid (Optional) Filter by an album, as returned by
+ * photos_getAlbums.
+ * @param string $pids (Optional) Restrict to a comma-separated list of pids
+ *
* @return array An array of photo objects.
*/
public function &get($subj_id = null, $aid = null, $pids = null)
/**
* Returns the albums created by the given user.
*
- * @param int $uid (Optional) The uid of the user whose albums you want.
- * A null will return the albums of the session user.
- * @param string $aids (Optional) A comma-separated list of aids to restricti
- * the query.
- *
* Note that at least one of the (uid, aids) parameters must be specified.
*
- * @returns an array of album objects.
+ * @param integer $uid (Optional) The uid of the user whose albums you want.
+ * A null will return the albums of the session user.
+ * @param string $aids (Optional) A comma-separated list of aids to restricti
+ * the query.
+ *
+ * @return array of album objects.
*/
public function &getAlbums($uid = null, $aids = null)
{
/**
* Uploads a photo.
*
- * @param string $file The location of the photo on the local filesystem.
- * @param int $aid (Optional) The album into which to upload the
- * photo.
- * @param string $caption (Optional) A caption for the photo.
- * @param int uid (Optional) The user ID of the user whose photo you
- * are uploading
+ * @param string $file The location of the photo on the local filesystem.
+ * @param integer $aid (Optional) The album into which to upload the
+ * photo.
+ * @param string $caption (Optional) A caption for the photo.
+ * @param integer $uid (Optional) The user ID of the user whose photo you
+ * are uploading
*
* @return array An array of user objects
*/
protected $_method;
protected $_params;
+ /**
+ * Const'r
+ *
+ * @param Horde_Service_Facebook $facebook
+ * @param string $method
+ * @param Horde_Http_Client $http_client
+ * @param array $params
+ */
public function __construct($facebook, $method, $http_client, $params = array())
{
$this->_facebook = $facebook;
/**
* Run this request and return the data.
*
- * @throws Horde_Service_Facebook_Exception
- *
* @param string $dataFormat Optionally specify the datatype to return.
*
- * @return Either raw XML, JSON, or an array of decoded values.
+ * @return mixed Either raw XML, JSON, or an array of decoded values.
+ * @throws Horde_Service_Facebook_Exception
*/
public function &run()
{
}
/**
+ * Send a POST request
+ *
+ * @param string $method The method to call.
+ * @param array $params The method parameters.
+ *
+ * @return string The request results
* @throws Horde_Service_Facebook_Exception
- * @param $method
- * @param $params
- * @return unknown_type
*/
protected function _postRequest($method, &$params)
{
}
/**
+ * Finalize, sanity check, standardze and sign the method parameters, $params
+ *
+ * @param string $method The method name
+ * @param array $params Method parameters
*
- * @param $method
- * @param $params
- * @return unknown_type
+ * @return void
*/
protected function _finalizeParams($method, &$params)
{
$params['sig'] = Horde_Service_Facebook_Auth::generateSignature($params, $this->_facebook->secret);
}
+ /**
+ * Adds standard facebook api parameters to $params
+ *
+ * @param string $method The method name
+ * @param array $params Method parameters
+ *
+ * @return void
+ */
protected function _addStandardParams($method, &$params)
{
// Select the correct data format.
}
}
+ /**
+ * Helper function to convert array to CSV string
+ *
+ * @param array $params
+ * @return string
+ */
protected function _convertToCsv(&$params)
{
foreach ($params as $key => &$val) {
}
/**
+ * Create a string suitable for sending as POST data.
+ *
* TODO: Figure out why using http_build_query doesn't work here.
*
+ * @param array $params The parameters array
+ *
+ * @return string The POST string
*/
protected function _createPostString($params)
{
return implode('&', $post_params);
}
+ /**
+ *
+ * @param string $xml
+ *
+ * @return array
+ */
private function _xmlToResult($xml)
{
$sxml = simplexml_load_string($xml);
return $result;
}
+ /**
+ *
+ * @param string $sxml
+ *
+ * @return array
+ */
private static function _simplexmlToArray($sxml)
{
$arr = array();
*
* @param string $viewerId The user id or page id of the page whose stream
* to read.
- * @param array $sourceIds
+ * @param array $sourceIds
* @param timestamp $start
* @param timestamp $end
- * @param int $limit
- * @param string $filterKey
+ * @param integer $limit
+ * @param string $filterKey
+ *
+ * @return mixed Method call results.
*/
function &get($viewerId = '', $sourceIds = array(), $start = '', $end = '',
$limit = '', $filterKey = '')
* @param string $postId The post id of the post whose comments we are
* retrieving.
*
- * @return array
+ * @return mixed
*/
function &getComments($postId)
{
* see the API docs.
* @param string $action_links Array of action links.
* @param string $target_id The id of user/page you are publishing to.
+ *
+ * @return mixed
*/
function publish($message = '', $attachment = '', $action_links = '', $target_id = '', $uid = '')
{
/**
* Remove a post from a user's stream
*
- * @param string $post_id The post id
+ * @param string $postId The post id
* @param string $uid The user id
*
- * @return unknown_type
+ * @return mixed
*/
function remove($postId, $uid = '')
{
/**
* Add a comment to a user's post.
*
- * @param string $post_id The post id the comment belongs to
+ * @param string $postId The post id the comment belongs to
* @param string $comment The body of the comment (text only, no HTML).
* @param string $uid The user id of the user who is posting the
* comment.
/**
* Remove a comment from a post.
*
- * @param string $comment_id The comment id to remove.
+ * @param string $commentId The comment id to remove.
* @param string $uid User id
*
* @return boolean
/**
* Add a "like" to a post.
*
- * @param string $post_id
+ * @param string $postId
* @param string $uid
*
- * @return unknown_type
+ * @return mixed
*/
function addLike($postId, $uid = '')
{
*/
class Horde_Service_Facebook_UploadRequest extends Horde_Service_Facebook_Request
{
+ /**
+ * Filename to upload
+ *
+ * @var string
+ */
protected $_filename;
+ /**
+ * Const'r
+ *
+ * @param Horde_Service_Facebook $facebook
+ * @param string $method
+ * @param Horde_Http_Client $http_client
+ * @param string $file
+ * @param array $params
+ */
public function __construct($facebook, $method, $http_client, $file, $params = array())
{
parent::__construct($facebook, $method, $http_client, $params);
$this->_filename = $file;
}
+ /**
+ * Run the request
+ *
+ * @return mixed
+ */
public function run()
{
// Ensure we ask for JSON
* Returns 1 if the user has the specified permission, 0 otherwise.
* http://wiki.developers.facebook.com/index.php/Users.hasAppPermission
*
- * @throws Horde_Service_Facebook_Exception
+ * @param string $ext_perm The perm to check for.
+ * @param string $uid The facebook userid to check.
+ *
* @return integer 1 or 0
+ * @throws Horde_Service_Facebook_Exception
*/
public function &hasAppPermission($ext_perm, $uid = null)
{
* Returns whether or not the user corresponding to the current
* session object has the give the app basic authorization.
*
+ * @param string $uid Facebook userid
+ *
* @throws Horde_Service_Facebook_Exception
* @return boolean true if the user has authorized the app
*/
* Example: setStatus("is loving the API!")
* will produce the status "Luke is loving the API!"
*
- * @param string $status text-only message to set
- * @param int $uid user to set for (defaults to the
- * logged-in user)
- * @param bool $clear whether or not to clear the status,
- * instead of setting it
- * @param bool $status_includes_verb if true, the word "is" will *not* be
- * prepended to the status message
+ * @param string $status text-only message to set
+ * @param string $uid user to set for (defaults to the
+ * logged-in user)
+ * @param boolean $clear whether or not to clear the status, instead
+ * of setting it
+ * @param boolean $includeVerb If true, the word "is" will *not* be
+ * prepended to the status message
*
* @return boolean
*/
return $this->_facebook->callMethod('facebook.users.setStatus', $params);
}
+ /**
+ * Get user's status
+ *
+ * @param string $uid
+ * @param integer $limit
+ *
+ * @return mixed
+ */
public function &getStatus($uid = null, $limit = 1)
{
if (empty($uid) && !$skey = $this->_facebook->auth->getSessionKey()) {