You've already forked joomla_test
first commit
This commit is contained in:
201
libraries/joomla/facebook/album.php
Normal file
201
libraries/joomla/facebook/album.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Album class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/album/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookAlbum extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get an album. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getAlbum($album)
|
||||
{
|
||||
return $this->get($album);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the photos contained in this album. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPhotos($album, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($album, 'photos', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add photos to an album. Note: check can_upload flag first. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
* @param string $source Path to photo.
|
||||
* @param string $message Photo description.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createPhoto($album, $source, $message = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data[basename($source)] = '@' . realpath($source);
|
||||
|
||||
if ($message)
|
||||
{
|
||||
$data['message'] = $message;
|
||||
}
|
||||
|
||||
return $this->createConnection($album, 'photos', $data, array('Content-Type' => 'multipart/form-data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an album's comments. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($album, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($album, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to comment on an album. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($album, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($album, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get album's likes. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($album, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($album, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like an album. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($album)
|
||||
{
|
||||
return $this->createConnection($album, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike an album. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($album)
|
||||
{
|
||||
return $this->deleteConnection($album, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the album's cover photo, the first picture uploaded to an album becomes the cover photo for the album.
|
||||
* Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $album The album id.
|
||||
* @param boolean $redirect If false this will return the URL of the picture without a 302 redirect.
|
||||
*
|
||||
* @return string URL of the picture.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPicture($album, $redirect = true)
|
||||
{
|
||||
$extra_fields = '';
|
||||
|
||||
if ($redirect == false)
|
||||
{
|
||||
$extra_fields = '?redirect=false';
|
||||
}
|
||||
|
||||
return $this->getConnection($album, 'picture', $extra_fields);
|
||||
}
|
||||
}
|
135
libraries/joomla/facebook/checkin.php
Normal file
135
libraries/joomla/facebook/checkin.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Checkin class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/checkin/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookCheckin extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a checkin. Requires authentication and user_checkins or friends_checkins permission.
|
||||
*
|
||||
* @param string $checkin The checkin id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getCheckin($checkin)
|
||||
{
|
||||
return $this->get($checkin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a checkin's comments. Requires authentication and user_checkins or friends_checkins permission.
|
||||
*
|
||||
* @param string $checkin The checkin id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($checkin, $limit=0, $offset=0, $until=null, $since=null)
|
||||
{
|
||||
return $this->getConnection($checkin, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a comment to the checkin. Requires authentication and publish_stream and user_checkins or friends_checkins permission.
|
||||
*
|
||||
* @param string $checkin The checkin id.
|
||||
* @param string $message The checkin's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($checkin, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($checkin, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a checkin's likes. Requires authentication and user_checkins or friends_checkins permission.
|
||||
*
|
||||
* @param string $checkin The checkin id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($checkin, $limit=0, $offset=0, $until=null, $since=null)
|
||||
{
|
||||
return $this->getConnection($checkin, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like a checkin. Requires authentication and publish_stream and user_checkins or friends_checkins permission.
|
||||
*
|
||||
* @param string $checkin The checkin id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($checkin)
|
||||
{
|
||||
return $this->createConnection($checkin, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a checkin. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $checkin The checkin id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($checkin)
|
||||
{
|
||||
return $this->deleteConnection($checkin, 'likes');
|
||||
}
|
||||
}
|
135
libraries/joomla/facebook/comment.php
Normal file
135
libraries/joomla/facebook/comment.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Comment class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/Comment/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookComment extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a comment. Requires authentication.
|
||||
*
|
||||
* @param string $comment The comment id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComment($comment)
|
||||
{
|
||||
return $this->get($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $comment The comment id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a comment's comments. Requires authentication.
|
||||
*
|
||||
* @param string $comment The comment id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($comment, $limit=0, $offset=0, $until=null, $since=null)
|
||||
{
|
||||
return $this->getConnection($comment, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to comment on a comment. Requires authentication with publish_stream permission.
|
||||
*
|
||||
* @param string $comment The comment id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($comment, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($comment, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get comment's likes. Requires authentication.
|
||||
*
|
||||
* @param string $comment The comment id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($comment, $limit=0, $offset=0, $until=null, $since=null)
|
||||
{
|
||||
return $this->getConnection($comment, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like a comment. Requires authentication and publish_stram permission.
|
||||
*
|
||||
* @param string $comment The comment id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($comment)
|
||||
{
|
||||
return $this->createConnection($comment, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a comment. Requires authentication and publish_stram permission.
|
||||
*
|
||||
* @param string $comment The comment id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment, 'likes');
|
||||
}
|
||||
}
|
523
libraries/joomla/facebook/event.php
Normal file
523
libraries/joomla/facebook/event.php
Normal file
@ -0,0 +1,523 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API User class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/event/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookEvent extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get information about an event visible to the current user. Requires authentication.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getEvent($event)
|
||||
{
|
||||
return $this->get($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the event's wall. Requires authentication.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFeed($event, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($event, 'feed', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a link on event's feed which the current_user is or maybe attending. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param string $link Link URL.
|
||||
* @param string $message Link message.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLink($event, $link, $message = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['link'] = $link;
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($event, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a link. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param mixed $link The Link ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLink($link)
|
||||
{
|
||||
return $this->deleteConnection($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post on event's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param string $message Post message.
|
||||
* @param string $link Post URL.
|
||||
* @param string $picture Post thumbnail image (can only be used if link is specified)
|
||||
* @param string $name Post name (can only be used if link is specified).
|
||||
* @param string $caption Post caption (can only be used if link is specified).
|
||||
* @param string $description Post description (can only be used if link is specified).
|
||||
* @param array $actions Post actions array of objects containing name and link.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createPost($event, $message = null, $link = null, $picture = null, $name = null, $caption = null,
|
||||
$description = null, $actions = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
$data['link'] = $link;
|
||||
$data['name'] = $name;
|
||||
$data['caption'] = $caption;
|
||||
$data['description'] = $description;
|
||||
$data['actions'] = $actions;
|
||||
$data['picture'] = $picture;
|
||||
|
||||
return $this->createConnection($event, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a post. Note: you can only delete the post if it was created by the current user.
|
||||
* Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $post The Post ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deletePost($post)
|
||||
{
|
||||
return $this->deleteConnection($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a status message on behalf of the user on the event's wall. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param string $message Status message content.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createStatus($event, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($event, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a status. Note: you can only delete the post if it was created by the current user.
|
||||
* Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $status The Status ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteStatus($status)
|
||||
{
|
||||
return $this->deleteConnection($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the list of invitees for the event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getInvited($event, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($event, 'invited', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if a user is invited to the event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
*
|
||||
* @return array The decoded JSON response or an empty array if the user is not invited.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function isInvited($event, $user)
|
||||
{
|
||||
return $this->getConnection($event, 'invited/' . $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to invite users to the event. Requires authentication and create_event permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param string $users Comma separated list of user ids.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createInvite($event, $users)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['users'] = $users;
|
||||
|
||||
return $this->createConnection($event, 'invited', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a invitation. Note: you can only delete the invite if the current user is the event admin.
|
||||
* Requires authentication and rsvp_event permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param string $user The user id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteInvite($event, $user)
|
||||
{
|
||||
return $this->deleteConnection($event, 'invited/' . $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the list of attending users. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getAttending($event, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($event, 'attending', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if a user is attending an event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
*
|
||||
* @return array The decoded JSON response or an empty array if the user is not invited.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function isAttending($event, $user)
|
||||
{
|
||||
return $this->getConnection($event, 'attending/' . $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the current user as attending. Requires authentication and rsvp_event permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createAttending($event)
|
||||
{
|
||||
return $this->createConnection($event, 'attending');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the list of maybe attending users. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getMaybe($event, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($event, 'maybe', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if a user is maybe attending an event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
*
|
||||
* @return array The decoded JSON response or an empty array if the user is not invited.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function isMaybe($event, $user)
|
||||
{
|
||||
return $this->getConnection($event, 'maybe/' . $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the current user as maybe attending. Requires authentication and rscp_event permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createMaybe($event)
|
||||
{
|
||||
return $this->createConnection($event, 'maybe');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the list of users which declined the event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getDeclined($event, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($event, 'declined', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if a user responded 'no' to the event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
*
|
||||
* @return array The decoded JSON response or an empty array if the user is not invited.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function isDeclined($event, $user)
|
||||
{
|
||||
return $this->getConnection($event, 'declined/' . $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the current user as declined. Requires authentication and rscp_event permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createDeclined($event)
|
||||
{
|
||||
return $this->createConnection($event, 'declined');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the list of users which have not replied to the event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getNoreply($event, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($event, 'noreply', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if a user has not replied to the event. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
*
|
||||
* @return array The decoded JSON response or an empty array if the user is not invited.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function isNoreply($event, $user)
|
||||
{
|
||||
return $this->getConnection($event, 'noreply/' . $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the event's profile picture. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param boolean $redirect If false this will return the URL of the picture without a 302 redirect.
|
||||
* @param string $type To request a different photo use square | small | normal | large.
|
||||
*
|
||||
* @return string The URL to the event's profile picture.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPicture($event, $redirect = true, $type = null)
|
||||
{
|
||||
$extra_fields = '';
|
||||
|
||||
if ($redirect == false)
|
||||
{
|
||||
$extra_fields = '?redirect=false';
|
||||
}
|
||||
|
||||
if ($type)
|
||||
{
|
||||
$extra_fields .= (strpos($extra_fields, '?') === false) ? '?type=' . $type : '&type=' . $type;
|
||||
}
|
||||
|
||||
return $this->getConnection($event, 'picture', $extra_fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get photos published on event's wall. Requires authentication.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPhotos($event, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($event, 'photos', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a photo on event's wall. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param string $source Path to photo.
|
||||
* @param string $message Photo description.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createPhoto($event, $source, $message = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data[basename($source)] = '@' . realpath($source);
|
||||
|
||||
if ($message)
|
||||
{
|
||||
$data['message'] = $message;
|
||||
}
|
||||
|
||||
return $this->createConnection($event, 'photos', $data, array('Content-Type' => 'multipart/form-data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get videos published on event's wall. Requires authentication.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getVideos($event, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($event, 'videos', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a video on event's wall. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $event The event id.
|
||||
* @param string $source Path to photo.
|
||||
* @param string $title Video title.
|
||||
* @param string $description Video description.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createVideo($event, $source, $title = null, $description = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data[basename($source)] = '@' . realpath($source);
|
||||
|
||||
if ($title)
|
||||
{
|
||||
$data['title'] = $title;
|
||||
}
|
||||
|
||||
if ($description)
|
||||
{
|
||||
$data['description'] = $description;
|
||||
}
|
||||
|
||||
return $this->createConnection($event, 'videos', $data, array('Content-Type' => 'multipart/form-data'));
|
||||
}
|
||||
}
|
187
libraries/joomla/facebook/facebook.php
Normal file
187
libraries/joomla/facebook/facebook.php
Normal file
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Joomla Platform class for interacting with a Facebook API instance.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebook
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the Facebook object.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var JHttp The HTTP client object to use in sending HTTP requests.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var JFacebookOAuth The OAuth client.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $oauth;
|
||||
|
||||
/**
|
||||
* @var JFacebookUser Facebook API object for user.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var JFacebookStatus Facebook API object for status.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* @var JFacebookCheckin Facebook API object for checkin.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $checkin;
|
||||
|
||||
/**
|
||||
* @var JFacebookEvent Facebook API object for event.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $event;
|
||||
|
||||
/**
|
||||
* @var JFacebookGroup Facebook API object for group.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/**
|
||||
* @var JFacebookLink Facebook API object for link.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* @var JFacebookNote Facebook API object for note.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $note;
|
||||
|
||||
/**
|
||||
* @var JFacebookPost Facebook API object for post.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $post;
|
||||
|
||||
/**
|
||||
* @var JFacebookComment Facebook API object for comment.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
/**
|
||||
* @var JFacebookPhoto Facebook API object for photo.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $photo;
|
||||
|
||||
/**
|
||||
* @var JFacebookVideo Facebook API object for video.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $video;
|
||||
|
||||
/**
|
||||
* @var JFacebookAlbum Facebook API object for album.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $album;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JFacebookOAuth $oauth OAuth client.
|
||||
* @param JRegistry $options Facebook options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function __construct(JFacebookOAuth $oauth = null, JRegistry $options = null, JHttp $client = null)
|
||||
{
|
||||
$this->oauth = $oauth;
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
$this->client = isset($client) ? $client : new JHttp($this->options);
|
||||
|
||||
// Setup the default API url if not already set.
|
||||
$this->options->def('api.url', 'https://graph.facebook.com/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to lazily create API objects
|
||||
*
|
||||
* @param string $name Name of property to retrieve
|
||||
*
|
||||
* @return JFacebookObject Facebook API object (status, user, friends etc).
|
||||
*
|
||||
* @since 13.1
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$class = 'JFacebook' . ucfirst($name);
|
||||
|
||||
if (class_exists($class))
|
||||
{
|
||||
if (false == isset($this->$name))
|
||||
{
|
||||
$this->$name = new $class($this->options, $this->client, $this->oauth);
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Argument %s produced an invalid class name: %s', $name, $class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option from the JFacebook instance.
|
||||
*
|
||||
* @param string $key The name of the option to get.
|
||||
*
|
||||
* @return mixed The option value.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
return $this->options->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the JFacebook instance.
|
||||
*
|
||||
* @param string $key The name of the option to set.
|
||||
* @param mixed $value The option value to set.
|
||||
*
|
||||
* @return JFacebook This object for method chaining.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$this->options->set($key, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
254
libraries/joomla/facebook/group.php
Normal file
254
libraries/joomla/facebook/group.php
Normal file
@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Group class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/group/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookGroup extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to read a group. Requires authentication and user_groups or friends_groups permission for non-public groups.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getGroup($group)
|
||||
{
|
||||
return $this->get($group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the group's wall. Requires authentication and user_groups or friends_groups permission for non-public groups.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFeed($group, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($group, 'feed', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the group's members. Requires authentication and user_groups or friends_groups permission for non-public groups.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getMembers($group, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($group, 'members', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the group's docs. Requires authentication and user_groups or friends_groups permission for non-public groups.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getDocs($group, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($group, 'docs', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the groups's picture. Requires authentication and user_groups or friends_groups permission.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
* @param string $type To request a different photo use square | small | normal | large.
|
||||
*
|
||||
* @return string The URL to the group's picture.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPicture($group, $type = null)
|
||||
{
|
||||
if ($type)
|
||||
{
|
||||
$type = '?type=' . $type;
|
||||
}
|
||||
|
||||
return $this->getConnection($group, 'picture', $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a link on group's wall. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
* @param string $link Link URL.
|
||||
* @param strin $message Link message.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLink($group, $link, $message = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['link'] = $link;
|
||||
|
||||
if ($message)
|
||||
{
|
||||
$data['message'] = $message;
|
||||
}
|
||||
|
||||
return $this->createConnection($group, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a link. Requires authentication.
|
||||
*
|
||||
* @param mixed $link The Link ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLink($link)
|
||||
{
|
||||
return $this->deleteConnection($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post on group's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
* @param string $message Post message.
|
||||
* @param string $link Post URL.
|
||||
* @param string $picture Post thumbnail image (can only be used if link is specified)
|
||||
* @param string $name Post name (can only be used if link is specified).
|
||||
* @param string $caption Post caption (can only be used if link is specified).
|
||||
* @param string $description Post description (can only be used if link is specified).
|
||||
* @param array $actions Post actions array of objects containing name and link.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createPost($group, $message = null, $link = null, $picture = null, $name = null, $caption = null,
|
||||
$description = null, $actions = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
if ($message)
|
||||
{
|
||||
$data['message'] = $message;
|
||||
}
|
||||
|
||||
if ($link)
|
||||
{
|
||||
$data['link'] = $link;
|
||||
}
|
||||
|
||||
if ($name)
|
||||
{
|
||||
$data['name'] = $name;
|
||||
}
|
||||
|
||||
if ($caption)
|
||||
{
|
||||
$data['caption'] = $caption;
|
||||
}
|
||||
|
||||
if ($description)
|
||||
{
|
||||
$data['description'] = $description;
|
||||
}
|
||||
|
||||
if ($actions)
|
||||
{
|
||||
$data['actions'] = $actions;
|
||||
}
|
||||
|
||||
if ($picture)
|
||||
{
|
||||
$data['picture'] = $picture;
|
||||
}
|
||||
|
||||
return $this->createConnection($group, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a post. Note: you can only delete the post if it was created by the current user. Requires authentication.
|
||||
*
|
||||
* @param string $post The Post ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deletePost($post)
|
||||
{
|
||||
return $this->deleteConnection($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a status message on behalf of the user on the group's wall. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $group The group id.
|
||||
* @param string $message Status message content.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createStatus($group, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($group, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a status. Note: you can only delete the status if it was created by the current user. Requires authentication.
|
||||
*
|
||||
* @param string $status The Status ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteStatus($status)
|
||||
{
|
||||
return $this->deleteConnection($status);
|
||||
}
|
||||
}
|
1
libraries/joomla/facebook/index.html
Normal file
1
libraries/joomla/facebook/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
135
libraries/joomla/facebook/link.php
Normal file
135
libraries/joomla/facebook/link.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Link class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/link/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookLink extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a link. Requires authentication and read_stream permission for non-public links.
|
||||
*
|
||||
* @param string $link The link id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLink($link)
|
||||
{
|
||||
return $this->get($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a link's comments. Requires authentication and read_stream permission for non-public links.
|
||||
*
|
||||
* @param string $link The link id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($link, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($link, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to comment on a link. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $link The link id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($link, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($link, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get link's likes. Requires authentication and read_stream permission for non-public links.
|
||||
*
|
||||
* @param string $link The link id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($link, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($link, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like a link. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $link The link id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($link)
|
||||
{
|
||||
return $this->createConnection($link, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a link. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param string $link The link id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($link)
|
||||
{
|
||||
return $this->deleteConnection($link, 'likes');
|
||||
}
|
||||
}
|
135
libraries/joomla/facebook/note.php
Normal file
135
libraries/joomla/facebook/note.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Note class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/note/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookNote extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a note. Requires authentication and user_notes or friends_notes permission for non-public notes.
|
||||
*
|
||||
* @param string $note The note id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getNote($note)
|
||||
{
|
||||
return $this->get($note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a note's comments. Requires authentication and user_notes or friends_notes permission for non-public notes.
|
||||
*
|
||||
* @param string $note The note id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($note, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($note, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to comment on a note. Requires authentication and publish_stream and user_notes or friends_notes permissions.
|
||||
*
|
||||
* @param string $note The note id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($note, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($note, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream and user_notes or friends_notes permissions.
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get note's likes. Requires authentication and user_notes or friends_notes for non-public notes.
|
||||
*
|
||||
* @param string $note The note id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($note, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($note, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like a note. Requires authentication and publish_stream and user_notes or friends_notes permissions.
|
||||
*
|
||||
* @param string $note The note id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($note)
|
||||
{
|
||||
return $this->createConnection($note, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a note. Requires authentication and publish_stream and user_notes or friends_notes permissions.
|
||||
*
|
||||
* @param string $note The note id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($note)
|
||||
{
|
||||
return $this->deleteConnection($note, 'likes');
|
||||
}
|
||||
}
|
77
libraries/joomla/facebook/oauth.php
Normal file
77
libraries/joomla/facebook/oauth.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Joomla Platform class for generating Facebook API access token.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookOAuth extends JOAuth2Client
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the JFacebookOAuth object.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JRegistry $options JFacebookOauth options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
* @param JInput $input The input object.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function __construct(JRegistry $options = null, JHttp $client = null, JInput $input = null)
|
||||
{
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
|
||||
// Setup the authentication and token urls if not already set.
|
||||
$this->options->def('authurl', 'http://www.facebook.com/dialog/oauth');
|
||||
$this->options->def('tokenurl', 'https://graph.facebook.com/oauth/access_token');
|
||||
|
||||
// Call the JOauthOauth2client constructor to setup the object.
|
||||
parent::__construct($this->options, $client, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to set permissions.
|
||||
*
|
||||
* @param string $scope Comma separated list of permissions.
|
||||
*
|
||||
* @return JFacebookOauth This object for method chaining
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function setScope($scope)
|
||||
{
|
||||
$this->setOption('scope', $scope);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the current scope
|
||||
*
|
||||
* @return string Comma separated list of permissions.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getScope()
|
||||
{
|
||||
return $this->getOption('scope');
|
||||
}
|
||||
}
|
306
libraries/joomla/facebook/object.php
Normal file
306
libraries/joomla/facebook/object.php
Normal file
@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API object class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
abstract class JFacebookObject
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the Facebook object.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var JHttp The HTTP client object to use in sending HTTP requests.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var JFacebookOAuth The OAuth client.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $oauth;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JRegistry $options Facebook options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
* @param JFacebookOAuth $oauth The OAuth client.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function __construct(JRegistry $options = null, JHttp $client = null, JFacebookOAuth $oauth = null)
|
||||
{
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
$this->client = isset($client) ? $client : new JHttp($this->options);
|
||||
$this->oauth = $oauth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request. This method will
|
||||
* add appropriate pagination details if necessary and also prepend the API url
|
||||
* to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param timestamp $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param timestamp $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return string The request URL.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
protected function fetchUrl($path, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
// Get a new JUri object fousing the api url and given path.
|
||||
$uri = new JUri($this->options->get('api.url') . $path);
|
||||
|
||||
if ($limit > 0)
|
||||
{
|
||||
$uri->setVar('limit', (int) $limit);
|
||||
}
|
||||
|
||||
if ($offset > 0)
|
||||
{
|
||||
$uri->setVar('offset', (int) $offset);
|
||||
}
|
||||
|
||||
if ($until != null)
|
||||
{
|
||||
$uri->setVar('until', $until);
|
||||
}
|
||||
|
||||
if ($since != null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
|
||||
return (string) $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to send the request.
|
||||
*
|
||||
* @param string $path The path of the request to make.
|
||||
* @param mixed $data Either an associative array or a string to be sent with the post request.
|
||||
* @param array $headers An array of name-value pairs to include in the header of the request
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The request response.
|
||||
*
|
||||
* @since 13.1
|
||||
* @throws DomainException
|
||||
*/
|
||||
public function sendRequest($path, $data = '', array $headers = null, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
// Send the request.
|
||||
$response = $this->client->get($this->fetchUrl($path, $limit, $offset, $until, $since), $headers);
|
||||
|
||||
$response = json_decode($response->body);
|
||||
|
||||
// Validate the response.
|
||||
if (property_exists($response, 'error'))
|
||||
{
|
||||
throw new RuntimeException($response->error->message);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an object.
|
||||
*
|
||||
* @param string $object The object id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function get($object)
|
||||
{
|
||||
if ($this->oauth != null)
|
||||
{
|
||||
if ($this->oauth->isAuthenticated())
|
||||
{
|
||||
$response = $this->oauth->query($this->fetchUrl($object));
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get object's connection.
|
||||
*
|
||||
* @param string $object The object id.
|
||||
* @param string $connection The object's connection name.
|
||||
* @param string $extra_fields URL fields.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getConnection($object, $connection = null, $extra_fields = '', $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
$path = $object . '/' . $connection . $extra_fields;
|
||||
|
||||
if ($this->oauth != null)
|
||||
{
|
||||
if ($this->oauth->isAuthenticated())
|
||||
{
|
||||
$response = $this->oauth->query($this->fetchUrl($path, $limit, $offset, $until, $since));
|
||||
|
||||
if (strcmp($response->body, ''))
|
||||
{
|
||||
return json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $response->headers['Location'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, '', null, $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create a connection.
|
||||
*
|
||||
* @param string $object The object id.
|
||||
* @param string $connection The object's connection name.
|
||||
* @param array $parameters The POST request parameters.
|
||||
* @param array $headers An array of name-value pairs to include in the header of the request
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createConnection($object, $connection = null, $parameters = null, array $headers = null)
|
||||
{
|
||||
if ($this->oauth->isAuthenticated())
|
||||
{
|
||||
// Build the request path.
|
||||
if ($connection != null)
|
||||
{
|
||||
$path = $object . '/' . $connection;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = $object;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
$response = $this->oauth->query($this->fetchUrl($path), $parameters, $headers, 'post');
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a connection.
|
||||
*
|
||||
* @param string $object The object id.
|
||||
* @param string $connection The object's connection name.
|
||||
* @param string $extra_fields URL fields.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteConnection($object, $connection = null, $extra_fields = '')
|
||||
{
|
||||
if ($this->oauth->isAuthenticated())
|
||||
{
|
||||
// Build the request path.
|
||||
if ($connection != null)
|
||||
{
|
||||
$path = $object . '/' . $connection . $extra_fields;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = $object . $extra_fields;
|
||||
}
|
||||
|
||||
// Send the delete request.
|
||||
$response = $this->oauth->query($this->fetchUrl($path), null, array(), 'delete');
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to set the OAuth client.
|
||||
*
|
||||
* @param JFacebookOAuth $oauth The OAuth client object.
|
||||
*
|
||||
* @return JFacebookObject This object for method chaining.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function setOAuth($oauth)
|
||||
{
|
||||
$this->oauth = $oauth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to get the OAuth client.
|
||||
*
|
||||
* @return JFacebookOAuth The OAuth client
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getOAuth()
|
||||
{
|
||||
return $this->oauth;
|
||||
}
|
||||
}
|
249
libraries/joomla/facebook/photo.php
Normal file
249
libraries/joomla/facebook/photo.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Photo class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/photo/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookPhoto extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a photo. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPhoto($photo)
|
||||
{
|
||||
return $this->get($photo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a photo's comments. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($photo, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($photo, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to comment on a photo. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($photo, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($photo, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get photo's likes. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($photo, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($photo, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like a photo. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($photo)
|
||||
{
|
||||
return $this->createConnection($photo, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a photo. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($photo)
|
||||
{
|
||||
return $this->deleteConnection($photo, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the Users tagged in the photo. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getTags($photo, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($photo, 'tags', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to tag one or more Users in a photo. $to or $tag_text required.
|
||||
* Requires authentication and publish_stream permission, user_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
* @param mixed $to ID of the User or an array of Users to tag in the photo: [{"id":"1234"}, {"id":"12345"}].
|
||||
* @param string $tag_text A text string to tag.
|
||||
* @param integer $x x coordinate of tag, as a percentage offset from the left edge of the picture.
|
||||
* @param integer $y y coordinate of tag, as a percentage offset from the top edge of the picture.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createTag($photo, $to = null, $tag_text = null, $x = null, $y = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
if (is_array($to))
|
||||
{
|
||||
$data['tags'] = $to;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['to'] = $to;
|
||||
}
|
||||
|
||||
if ($tag_text)
|
||||
{
|
||||
$data['tag_text'] = $tag_text;
|
||||
}
|
||||
|
||||
if ($x)
|
||||
{
|
||||
$data['x'] = $x;
|
||||
}
|
||||
|
||||
if ($y)
|
||||
{
|
||||
$data['y'] = $y;
|
||||
}
|
||||
|
||||
return $this->createConnection($photo, 'tags', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update the position of the tag for a particular Users in a photo.
|
||||
* Requires authentication and publish_stream permission, user_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
* @param string $to ID of the User to update tag in the photo.
|
||||
* @param integer $x x coordinate of tag, as a percentage offset from the left edge of the picture.
|
||||
* @param integer $y y coordinate of tag, as a percentage offset from the top edge of the picture.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function updateTag($photo, $to, $x = null, $y = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data['to'] = $to;
|
||||
|
||||
if ($x)
|
||||
{
|
||||
$data['x'] = $x;
|
||||
}
|
||||
|
||||
if ($y)
|
||||
{
|
||||
$data['y'] = $y;
|
||||
}
|
||||
|
||||
return $this->createConnection($photo, 'tags', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the album-sized view of the photo. Requires authentication and user_photos or friends_photos permission for private photos.
|
||||
*
|
||||
* @param string $photo The photo id.
|
||||
* @param boolean $redirect If false this will return the URL of the picture without a 302 redirect.
|
||||
*
|
||||
* @return string URL of the picture.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPicture($photo, $redirect = true)
|
||||
{
|
||||
$extra_fields = '';
|
||||
|
||||
if ($redirect == false)
|
||||
{
|
||||
$extra_fields = '?redirect=false';
|
||||
}
|
||||
|
||||
return $this->getConnection($photo, 'picture', $extra_fields);
|
||||
}
|
||||
}
|
148
libraries/joomla/facebook/post.php
Normal file
148
libraries/joomla/facebook/post.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Post class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/post/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookPost extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a post. Requires authentication and read_stream permission for all data.
|
||||
*
|
||||
* @param string $post The post id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPost($post)
|
||||
{
|
||||
return $this->get($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a post if it was created by this application. Requires authentication and publish_stream permission
|
||||
*
|
||||
* @param string $post The post id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deletePost($post)
|
||||
{
|
||||
return $this->deleteConnection($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a post's comments. Requires authentication and read_stream permission.
|
||||
*
|
||||
* @param string $post The post id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($post, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($post, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to comment on a post. Requires authentication and publish_stream permission
|
||||
*
|
||||
* @param string $post The post id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($post, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($post, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream permission
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get post's likes. Requires authentication and read_stream permission.
|
||||
*
|
||||
* @param string $post The post id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($post, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($post, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like a post. Requires authentication and publish_stream permission
|
||||
*
|
||||
* @param string $post The post id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($post)
|
||||
{
|
||||
return $this->createConnection($post, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a post. Requires authentication and publish_stream permission
|
||||
*
|
||||
* @param string $post The post id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($post)
|
||||
{
|
||||
return $this->deleteConnection($post, 'likes');
|
||||
}
|
||||
}
|
135
libraries/joomla/facebook/status.php
Normal file
135
libraries/joomla/facebook/status.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Status class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/status/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookStatus extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a status message. Requires authentication.
|
||||
*
|
||||
* @param string $status The status message id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getStatus($status)
|
||||
{
|
||||
return $this->get($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a status message's comments. Requires authentication.
|
||||
*
|
||||
* @param string $status The status message id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($status, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($status, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a comment to the status message. Requires authentication and publish_stream and user_status or friends_status permission.
|
||||
*
|
||||
* @param string $status The status message id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($status, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($status, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream and user_status or friends_status permission.
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a status message's likes. Requires authentication.
|
||||
*
|
||||
* @param string $status The status message id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($status, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($status, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like status message. Requires authentication and publish_stream and user_status or friends_status permission.
|
||||
*
|
||||
* @param string $status The status message id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($status)
|
||||
{
|
||||
return $this->createConnection($status, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a status message. Requires authentication and publish_stream and user_status or friends_status permission.
|
||||
*
|
||||
* @param string $status The status message id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($status)
|
||||
{
|
||||
return $this->deleteConnection($status, 'likes');
|
||||
}
|
||||
|
||||
}
|
991
libraries/joomla/facebook/user.php
Normal file
991
libraries/joomla/facebook/user.php
Normal file
@ -0,0 +1,991 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API User class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/user/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookUser extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get the specified user's details. Authentication is required only for some fields.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getUser($user)
|
||||
{
|
||||
return $this->get($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the specified user's friends. Requires authentication.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFriends($user, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($user, 'friends', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's incoming friend requests. Requires authentication and read_requests permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFriendRequests($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'friendrequests', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's friend lists. Requires authentication and read_friendlists permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFriendLists($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'friendlists', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's wall. Requires authentication and read_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFeed($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'feed', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's news feed. Requires authentication and read_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $filter User's stream filter.
|
||||
* @param boolean $location Retreive only posts with a location attached.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getHome($user, $filter = null, $location = false, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
$extra_fields = '';
|
||||
|
||||
if ($filter != null)
|
||||
{
|
||||
$extra_fields = '?filter=' . $filter;
|
||||
}
|
||||
|
||||
if ($location == true)
|
||||
{
|
||||
$extra_fields .= (strpos($extra_fields, '?') === false) ? '?with=location' : '&with=location';
|
||||
}
|
||||
|
||||
return $this->getConnection($user, 'home', $extra_fields, $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to see if a user is a friend of the current user. Requires authentication.
|
||||
*
|
||||
* @param mixed $current_user Either an integer containing the user ID or a string containing the username for the current user.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username for the user.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function hasFriend($current_user, $user)
|
||||
{
|
||||
return $this->getConnection($current_user, 'friends/' . $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get mutual friends of one user and the current user. Requires authentication.
|
||||
*
|
||||
* @param mixed $current_user Either an integer containing the user ID or a string containing the username for the current user.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username for the user.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getMutualFriends($current_user, $user, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($current_user, 'mutualfriends/' . $user, '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's profile picture. Requires authentication.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param boolean $redirect If false this will return the URL of the profile picture without a 302 redirect.
|
||||
* @param string $type To request a different photo use square | small | normal | large.
|
||||
*
|
||||
* @return string The URL to the user's profile picture.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPicture($user, $redirect = true, $type = null)
|
||||
{
|
||||
$extra_fields = '';
|
||||
|
||||
if ($redirect == false)
|
||||
{
|
||||
$extra_fields = '?redirect=false';
|
||||
}
|
||||
|
||||
if ($type != null)
|
||||
{
|
||||
$extra_fields .= (strpos($extra_fields, '?') === false) ? '?type=' . $type : '&type=' . $type;
|
||||
}
|
||||
|
||||
return $this->getConnection($user, 'picture', $extra_fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's family relationships. Requires authentication and user_relationships permission..
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFamily($user, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($user, 'family', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's notifications. Requires authentication and manage_notifications permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param boolean $read Enables you to see notifications that the user has already read.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getNotifications($user, $read = null, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
if ($read == true)
|
||||
{
|
||||
$read = '?include_read=1';
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->getConnection($user, 'notifications', $read, $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to mark a notification as read. Requires authentication and manage_notifications permission.
|
||||
*
|
||||
* @param string $notification The notification id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function updateNotification($notification)
|
||||
{
|
||||
$data['unread'] = 0;
|
||||
|
||||
return $this->createConnection($notification, null, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's permissions. Requires authentication.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPermissions($user, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($user, 'permissions', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to revoke a specific permission on behalf of a user. Requires authentication.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $permission The permission to revoke. If none specified, then this will de-authorize the application completely.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deletePermission($user, $permission = '')
|
||||
{
|
||||
return $this->deleteConnection($user, 'permissions', '?permission=' . $permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's albums. Requires authentication and user_photos or friends_photos permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getAlbums($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'albums', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create an album for a user. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $name Album name.
|
||||
* @param string $description Album description.
|
||||
* @param json $privacy A JSON-encoded object that defines the privacy setting for the album.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createAlbum($user, $name, $description = null, $privacy = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['name'] = $name;
|
||||
$data['description'] = $description;
|
||||
$data['privacy'] = $privacy;
|
||||
|
||||
return $this->createConnection($user, 'albums', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's checkins. Requires authentication and user_checkins or friends_checkins permission
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getCheckins($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'checkins', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create a checkin for a user. Requires authentication and publish_checkins permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $place Id of the Place Page.
|
||||
* @param string $coordinates A JSON-encoded string containing latitute and longitude.
|
||||
* @param string $tags Comma separated list of USER_IDs.
|
||||
* @param string $message A message to add to the checkin.
|
||||
* @param string $link A link to add to the checkin.
|
||||
* @param string $picture A picture to add to the checkin.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createCheckin($user, $place, $coordinates, $tags = null, $message = null, $link = null, $picture = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['place'] = $place;
|
||||
$data['coordinates'] = $coordinates;
|
||||
$data['tags'] = $tags;
|
||||
$data['message'] = $message;
|
||||
$data['link'] = $link;
|
||||
$data['picture'] = $picture;
|
||||
|
||||
return $this->createConnection($user, 'checkins', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's likes. Requires authentication and user_likes or friends_likes permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to see if a user likes a specific Page. Requires authentication.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $page Facebook ID of the Page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function likesPage($user, $page)
|
||||
{
|
||||
return $this->getConnection($user, 'likes/' . $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the current user's events. Requires authentication and user_events or friends_events permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getEvents($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'events', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create an event for a user. Requires authentication create_event permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $name Event name.
|
||||
* @param string $start_time Event start time as UNIX timestamp.
|
||||
* @param string $end_time Event end time as UNIX timestamp.
|
||||
* @param string $description Event description.
|
||||
* @param string $location Event location.
|
||||
* @param string $location_id Facebook Place ID of the place the Event is taking place.
|
||||
* @param string $privacy_type Event privacy setting, a string containing 'OPEN' (default), 'CLOSED', or 'SECRET'.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createEvent($user, $name, $start_time, $end_time = null, $description = null,
|
||||
$location = null, $location_id = null, $privacy_type = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['start_time'] = $start_time;
|
||||
$data['name'] = $name;
|
||||
$data['end_time'] = $end_time;
|
||||
$data['description'] = $description;
|
||||
$data['location'] = $location;
|
||||
$data['location_id'] = $location_id;
|
||||
$data['privacy_type'] = $privacy_type;
|
||||
|
||||
return $this->createConnection($user, 'events', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to edit an event. Requires authentication create_event permission.
|
||||
*
|
||||
* @param mixed $event Event ID.
|
||||
* @param string $name Event name.
|
||||
* @param string $start_time Event start time as UNIX timestamp.
|
||||
* @param string $end_time Event end time as UNIX timestamp.
|
||||
* @param string $description Event description.
|
||||
* @param string $location Event location.
|
||||
* @param string $location_id Facebook Place ID of the place the Event is taking place.
|
||||
* @param string $privacy_type Event privacy setting, a string containing 'OPEN' (default), 'CLOSED', or 'SECRET'.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function editEvent($event, $name = null, $start_time = null, $end_time = null, $description = null,
|
||||
$location = null, $location_id = null, $privacy_type = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['start_time'] = $start_time;
|
||||
$data['name'] = $name;
|
||||
$data['end_time'] = $end_time;
|
||||
$data['description'] = $description;
|
||||
$data['location'] = $location;
|
||||
$data['location_id'] = $location_id;
|
||||
$data['privacy_type'] = $privacy_type;
|
||||
|
||||
return $this->createConnection($event, null, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete an event. Note: you can only delete the event if it was created by the same app. Requires authentication create_event permission.
|
||||
*
|
||||
* @param string $event Event ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteEvent($event)
|
||||
{
|
||||
return $this->deleteConnection($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the groups that the user belongs to. Requires authentication and user_groups or friends_groups permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getGroups($user, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($user, 'groups', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's posted links. Requires authentication and user_groups or friends_groups permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLinks($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'links', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a link on user's feed. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $link Link URL.
|
||||
* @param strin $message Link message.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLink($user, $link, $message = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['link'] = $link;
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($user, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a link. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param mixed $link The Link ID.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLink($link)
|
||||
{
|
||||
return $this->deleteConnection($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's notes. Requires authentication and user_groups or friends_groups permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getNotes($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'notes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create a note on the behalf of the user.
|
||||
* Requires authentication and publish_stream permission, user_groups or friends_groups permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $subject The subject of the note.
|
||||
* @param string $message Note content.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createNote($user, $subject, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['subject'] = $subject;
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($user, 'notes', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's photos. Requires authentication and user_groups or friends_groups permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPhotos($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'photos', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a photo on user's wall. Requires authentication and publish_stream permission, user_groups or friends_groups permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $source Path to photo.
|
||||
* @param string $message Photo description.
|
||||
* @param string $place Facebook ID of the place associated with the photo.
|
||||
* @param boolean $no_story If set to 1, optionally suppresses the feed story that is automatically
|
||||
* generated on a user’s profile when they upload a photo using your application.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createPhoto($user, $source, $message = null, $place = null, $no_story = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data[basename($source)] = '@' . realpath($source);
|
||||
$data['message'] = $message;
|
||||
$data['place'] = $place;
|
||||
$data['no_story'] = $no_story;
|
||||
|
||||
return $this->createConnection($user, 'photos', $data, array('Content-Type' => 'multipart/form-data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's posts. Requires authentication and read_stream permission for non-public posts.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param boolean $location Retreive only posts with a location attached.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPosts($user, $location = false, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
if ($location == true)
|
||||
{
|
||||
$location = '?with=location';
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->getConnection($user, 'posts', $location, $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post on a user's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $message Post message.
|
||||
* @param string $link Post URL.
|
||||
* @param string $picture Post thumbnail image (can only be used if link is specified)
|
||||
* @param string $name Post name (can only be used if link is specified).
|
||||
* @param string $caption Post caption (can only be used if link is specified).
|
||||
* @param string $description Post description (can only be used if link is specified).
|
||||
* @param array $actions Post actions array of objects containing name and link.
|
||||
* @param string $place Facebook Page ID of the location associated with this Post.
|
||||
* @param string $tags Comma-separated list of Facebook IDs of people tagged in this Post.
|
||||
* For example: 1207059,701732. You cannot specify this field without also specifying a place.
|
||||
* @param string $privacy Post privacy settings (can only be specified if the Timeline being posted
|
||||
* on belongs to the User creating the Post).
|
||||
* @param string $object_attachment Facebook ID for an existing picture in the User's photo albums to use as the thumbnail image.
|
||||
* The User must be the owner of the photo, and the photo cannot be part of a message attachment.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createPost($user, $message = null, $link = null, $picture = null, $name = null, $caption = null,
|
||||
$description = null, $actions = null, $place = null, $tags = null, $privacy = null, $object_attachment = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
$data['link'] = $link;
|
||||
$data['name'] = $name;
|
||||
$data['caption'] = $caption;
|
||||
$data['description'] = $description;
|
||||
$data['actions'] = $actions;
|
||||
$data['place'] = $place;
|
||||
$data['tags'] = $tags;
|
||||
$data['privacy'] = $privacy;
|
||||
$data['object_attachment'] = $object_attachment;
|
||||
$data['picture'] = $picture;
|
||||
|
||||
return $this->createConnection($user, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a post. Note: you can only delete the post if it was created by the current user. Requires authentication
|
||||
*
|
||||
* @param string $post The Post ID.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deletePost($post)
|
||||
{
|
||||
return $this->deleteConnection($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's statuses. Requires authentication read_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getStatuses($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'statuses', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a status message on behalf of the user. Requires authentication publish_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $message Status message content.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createStatus($user, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($user, 'feed', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a status. Note: you can only delete the post if it was created by the current user.
|
||||
* Requires authentication publish_stream permission.
|
||||
*
|
||||
* @param string $status The Status ID.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteStatus($status)
|
||||
{
|
||||
return $this->deleteConnection($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the videos the user has been tagged in. Requires authentication and user_videos or friends_videos permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getVideos($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'videos', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a video on behalf of the user. Requires authentication and publish_stream permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param string $source Path to video.
|
||||
* @param string $title Video title.
|
||||
* @param string $description Video description.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createVideo($user, $source, $title = null, $description = null)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data[basename($source)] = '@' . realpath($source);
|
||||
$data['title'] = $title;
|
||||
$data['description'] = $description;
|
||||
|
||||
return $this->createConnection($user, 'videos', $data, array('Content-Type' => 'multipart/form-data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the posts the user has been tagged in. Requires authentication and user_videos or friends_videos permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getTagged($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'tagged', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the activities listed on the user's profile. Requires authentication and user_activities or friends_activities permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getActivities($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'activities', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the books listed on the user's profile. Requires authentication and user_likes or friends_likes permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getBooks($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'books', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the interests listed on the user's profile. Requires authentication.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getInterests($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'interests', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the movies listed on the user's profile. Requires authentication and user_likes or friends_likes permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getMovies($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'movies', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the television listed on the user's profile. Requires authentication and user_likes or friends_likes permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getTelevision($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'television', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the music listed on the user's profile. Requires authentication user_likes or friends_likes permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getMusic($user, $limit = 0, $offset = 0, $until = null, $since = null)
|
||||
{
|
||||
return $this->getConnection($user, 'music', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user's subscribers. Requires authentication and user_subscriptions or friends_subscriptions permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getSubscribers($user, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($user, 'subscribers', '', $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the people the user is subscribed to. Requires authentication and user_subscriptions or friends_subscriptions permission.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the username.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getSubscribedTo($user, $limit = 0, $offset = 0)
|
||||
{
|
||||
return $this->getConnection($user, 'subscribedto', '', $limit, $offset);
|
||||
}
|
||||
}
|
149
libraries/joomla/facebook/video.php
Normal file
149
libraries/joomla/facebook/video.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
|
||||
/**
|
||||
* Facebook API Video class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Facebook
|
||||
*
|
||||
* @see http://developers.facebook.com/docs/reference/api/video/
|
||||
* @since 13.1
|
||||
*/
|
||||
class JFacebookVideo extends JFacebookObject
|
||||
{
|
||||
/**
|
||||
* Method to get a video. Requires authentication and user_videos or friends_videos permission for private videos.
|
||||
*
|
||||
* @param string $video The video id.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getVideo($video)
|
||||
{
|
||||
return $this->get($video);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a video's comments. Requires authentication and user_videos or friends_videos permission for private videos.
|
||||
*
|
||||
* @param string $video The video id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($video, $limit=0, $offset=0, $until=null, $since=null)
|
||||
{
|
||||
return $this->getConnection($video, 'comments', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to comment on a video. Requires authentication and publish_stream permission, user_videos or friends_videos permission for private videos.
|
||||
*
|
||||
* @param string $video The video id.
|
||||
* @param string $message The comment's text.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createComment($video, $message)
|
||||
{
|
||||
// Set POST request parameters.
|
||||
$data = array();
|
||||
$data['message'] = $message;
|
||||
|
||||
return $this->createConnection($video, 'comments', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a comment. Requires authentication and publish_stream permission, user_videos or friends_videos permission for private videos.
|
||||
*
|
||||
* @param string $comment The comment's id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteComment($comment)
|
||||
{
|
||||
return $this->deleteConnection($comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get video's likes. Requires authentication and user_videos or friends_videos permission for private videos.
|
||||
*
|
||||
* @param string $video The video id.
|
||||
* @param integer $limit The number of objects per page.
|
||||
* @param integer $offset The object's number on the page.
|
||||
* @param string $until A unix timestamp or any date accepted by strtotime.
|
||||
* @param string $since A unix timestamp or any date accepted by strtotime.
|
||||
*
|
||||
* @return mixed The decoded JSON response or false if the client is not authenticated.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($video, $limit=0, $offset=0, $until=null, $since=null)
|
||||
{
|
||||
return $this->getConnection($video, 'likes', '', $limit, $offset, $until, $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like a video. Requires authentication and publish_stream permission, user_videos or friends_videos permission for private videos.
|
||||
*
|
||||
* @param string $video The video id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function createLike($video)
|
||||
{
|
||||
return $this->createConnection($video, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlike a video. Requires authentication and publish_stream permission, user_videos or friends_videos permission for private videos.
|
||||
*
|
||||
* @param string $video The video id.
|
||||
*
|
||||
* @return boolean Returns true if successful, and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteLike($video)
|
||||
{
|
||||
return $this->deleteConnection($video, 'likes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the album-sized view of the video. Requires authentication and user_videos or friends_videos permission for private photos.
|
||||
*
|
||||
* @param string $video The video id.
|
||||
*
|
||||
* @return string URL of the picture.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getPicture($video)
|
||||
{
|
||||
return $this->getConnection($video, 'picture');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user