class Horde_Service_Facebook
{
/**
- * The application's API Key
+ * Use only ssl resource flag
*
- * @var stirng
+ * @var boolean
*/
- public $api_key;
+ public $useSslResources = false;
/**
- * The API Secret Key
+ * The application's API Key
*
- * @var string
+ * @var stirng
*/
- public $secret;
+ protected $_apiKey;
/**
- * Use only ssl resource flag
+ * The API Secret Key
*
- * @var boolean
+ * @var string
*/
- public $useSslResources = false;
+ protected $_secret;
/**
* Holds the batch object when building a batch request.
*
* @var Horde_Service_Facebook_Batch
*/
- public $batchRequest;
+ protected $_batchRequest;
/**
* Holds an optional logger object
$this->_logDebug('Initializing Horde_Service_Facebook');
- $this->api_key = $api_key;
+ $this->_apiKey = $api_key;
$this->secret = $secret;
if (!empty($context['use_ssl'])) {
switch ($value) {
case 'internalFormat':
return $this->_internalFormat;
+ case 'apiKey':
+ return $this->_apiKey;
+ case 'secret':
+ return $this->_secret;
}
// If not, assume it's a method/action class...
}
/**
- * Return the current request's url
- *
- * @return string
- */
- protected function _current_url()
- {
- return sprintf("%s/%s", $this->_request->getHost(), $this->_request->getUri());
- }
-
- /**
* Helper function to get the appropriate facebook url
*
* @return string
*/
- public static function get_facebook_url($subdomain = 'www')
+ public static function getFacebookUrl($subdomain = 'www')
{
return 'http://' . $subdomain . '.facebook.com';
}
*/
public function get_login_url($next)
{
- return self::get_facebook_url() . '/login.php?v=1.0&api_key='
- . $this->api_key . ($next ? '&next=' . urlencode($next) : '');
+ return self::getFacebookUrl() . '/login.php?v=1.0&api_key='
+ . $this->_apiKey . ($next ? '&next=' . urlencode($next) : '');
}
/**
*/
public function batchBegin()
{
- if ($this->batchRequest !== null) {
+ if ($this->_batchRequest !== null) {
$code = Horde_Service_Facebook_ErrorCodes::API_EC_BATCH_ALREADY_STARTED;
$description = Horde_Service_Facebook_ErrorCodes::$api_error_descriptions[$code];
throw new Horde_Service_Facebook_Exception($description, $code);
}
- $this->batchRequest = new Horde_Service_Facebook_BatchRequest($this, $this->_http);
+ $this->_batchRequest = new Horde_Service_Facebook_BatchRequest($this, $this->_http);
}
/**
*/
public function batchEnd()
{
- if ($this->batchRequest === null) {
+ if ($this->_batchRequest === null) {
$code = Horde_Service_Facebook_ErrorCodes::API_EC_BATCH_NOT_STARTED;
$description = Horde_Service_Facebook_ErrorCodes::$api_error_descriptions[$code];
throw new Horde_Service_Facebook_Exception($description, $code);
}
- $this->batchRequest->run();
- $this->batchRequest = null;
+ $this->_batchRequest->run();
+ $this->_batchRequest = null;
}
/**
* 'delayed returns' when in a batch context.
* See: http://wiki.developers.facebook.com/index.php/Using_batching_API
*/
- public function &call_method($method, $params = array())
+ public function &callMethod($method, $params = array())
{
- if ($this->batchRequest === null) {
+ if ($this->_batchRequest === null) {
$request = new Horde_Service_Facebook_Request($this, $method, $this->_http, $params);
$results = &$request->run();
} else {
- $results = &$this->batchRequest->add($method, $params);
+ $results = &$this->_batchRequest->add($method, $params);
}
return $results;
*/
public function getAuthTokenUrl()
{
- return $this->_facebook->get_facebook_url() . '/code_gen.php?v=1.0&api_key='
- . $this->_facebook->api_key;
+ return $this->_facebook->getFacebookUrl() . '/code_gen.php?v=1.0&api_key='
+ . $this->_facebook->apiKey;
}
*/
public function getExtendedPermUrl($perm, $success_url = '', $cancel_url = '')
{
- return $this->_facebook->get_facebook_url() . '/authorize.php?v=1'
- . '&ext_perm=' . $perm . '&api_key=' . $this->_facebook->api_key
+ return $this->_facebook->getFacebookUrl() . '/authorize.php?v=1'
+ . '&ext_perm=' . $perm . '&api_key=' . $this->_facebook->apiKey
. (!empty($success_url) ? '&next=' . urlencode($success_url) : '')
. (!empty($cancel_url) ? '&cancel=' . urlencode($cancel_url) : '');
}
*/
public function getSession($auth_token)
{
- //Check if we are in batch mode
- if ($this->_facebook->batchRequest === null) {
- try {
- $results = $this->_facebook->call_method(
- 'facebook.auth.getSession',
- array('auth_token' => $auth_token));
- return $results;
- } catch (Horde_Service_Facebook_Exception $e) {
- if ($e->getCode() != Horde_Service_Facebook_ErrorCodes::API_EC_PARAM) {
- // API_EC_PARAM means we don't have a logged in user, otherwise who
- // knows what it means, so just throw it.
- throw $e;
- }
+ try {
+ $results = $this->_facebook->callMethod(
+ 'facebook.auth.getSession',
+ array('auth_token' => $auth_token));
+ return $results;
+ } catch (Horde_Service_Facebook_Exception $e) {
+ if ($e->getCode() != Horde_Service_Facebook_ErrorCodes::API_EC_PARAM) {
+ // API_EC_PARAM means we don't have a logged in user, otherwise who
+ // knows what it means, so just throw it.
+ throw $e;
}
}
}
*/
public function createToken()
{
- return $this->_facebook->call_method('facebook.auth.createToken');
+ return $this->_facebook->callMethod('facebook.auth.createToken');
}
/**
'No Session', Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('facebook.auth.expireSession', array('session_key' => $this->_sessionKey));
+ return $this->_facebook->callMethod('facebook.auth.expireSession', array('session_key' => $this->_sessionKey));
}
/**
public function expireSession()
{
if ($this->_expireSession()) {
- if ($this->_request->getCookie($this->_facebook->api_key . '_user')) {
+ if ($this->_request->getCookie($this->_facebook->apiKey . '_user')) {
$cookies = array('user', 'session_key', 'expires', 'ss');
foreach ($cookies as $name) {
- setcookie($this->_facebook->api_key . '_' . $name, false, time() - 3600);
+ setcookie($this->_facebook->apiKey . '_' . $name, false, time() - 3600);
}
- setcookie($this->_facebook->api_key, false, time() - 3600);
+ setcookie($this->_facebook->apiKey, false, time() - 3600);
}
// now, clear the rest of the stored state
$this->setUser($user, $sessionKey, $expires);
} elseif (!$ignore_cookies &&
- $fb_params = $this->_getParams($this->_request->getCookie(), null, $this->_facebook->api_key)) {
+ $fb_params = $this->_getParams($this->_request->getCookie(), null, $this->_facebook->apiKey)) {
// Nothing yet, try cookies...this is where we will get our values
// for an extenral web app accessing FB's API - assuming the session
// has already been retrieved previously.
- $base_domain_cookie = 'base_domain_' . $this->_facebook->api_key;
+ $base_domain_cookie = 'base_domain_' . $this->_facebook->apiKey;
if ($this->_request->getCookie($base_domain_cookie)) {
$this->_base_domain = $this->_request->getCookie($base_domain_cookie);
}
$cookies['expires'] = $expires;
}
foreach ($cookies as $name => $val) {
- setcookie($this->_facebook->api_key . '_' . $name, $val, (int)$expires, '', $this->_base_domain);
+ setcookie($this->_facebook->apiKey . '_' . $name, $val, (int)$expires, '', $this->_base_domain);
}
$sig = self::generateSignature($cookies, $this->_facebook->secret);
- setcookie($this->_facebook->api_key, $sig, (int)$expires, '', $this->_base_domain);
+ setcookie($this->_facebook->apiKey, $sig, (int)$expires, '', $this->_base_domain);
if ($this->_base_domain != null) {
- $base_domain_cookie = 'base_domain_' . $this->_facebook->api_key;
+ $base_domain_cookie = 'base_domain_' . $this->_facebook->apiKey;
setcookie($base_domain_cookie, $this->_base_domain, (int)$expires, '', $this->_base_domain);
}
}
*/
public function setUser($user, $sessionKey, $expires = null, $no_cookie = false)
{
- if ($no_cookie || !$this->_request->getCookie($this->_facebook->api_key . '_user') ||
- $this->_request->getCookie($this->_facebook->api_key . '_user') != $user) {
+ if ($no_cookie || !$this->_request->getCookie($this->_facebook->apiKey . '_user') ||
+ $this->_request->getCookie($this->_facebook->apiKey . '_user') != $user) {
$this->setCookies($user, $sessionKey, $expires);
}
$end_time = null, $rsvp_status = null)
{
// Note we return a reference to support batched calls
- // (see Horde_Service_Facebook::call_method)
- return $this->_facebook->call_method('facebook.events.get',
+ // (see Horde_Service_Facebook::callMethod)
+ return $this->_facebook->callMethod('facebook.events.get',
array('uid' => $uid,
'eids' => $eids,
'start_time' => $start_time,
*/
public function &getMembers($eid)
{
- return $this->_facebook->call_method('facebook.events.getMembers',
+ return $this->_facebook->callMethod('facebook.events.getMembers',
array('eid' => $eid,
'session_key' => $this->_facebook->auth->getSessionKey()));
}
*/
public function &rsvp($eid, $rsvp_status)
{
- return $this->_facebook->call_method('facebook.events.rsvp',
+ return $this->_facebook->callMethod('facebook.events.rsvp',
array('eid' => $eid,
'rsvp_status' => $rsvp_status,
'session_key' => $this->_facebook->auth->getSessionKey()));
*/
public function &cancel($eid, $cancel_message = '')
{
- return $this->_facebook->call_method('facebook.events.cancel',
+ return $this->_facebook->callMethod('facebook.events.cancel',
array('eid' => $eid,
'cancel_message' => $cancel_message,
'session_key' => $this->_facebook->auth->getSessionKey()));
*/
public function &create($event_info)
{
- return $this->_facebook->call_method('facebook.events.create',
+ return $this->_facebook->callMethod('facebook.events.create',
array('event_info' => $event_info,
'session_key' => $this->_facebook->auth->getSessionKey()));
}
*/
public function &edit($eid, $event_info)
{
- return $this->_facebook->call_method('facebook.events.edit',
+ return $this->_facebook->callMethod('facebook.events.edit',
array('eid' => $eid,
'event_info' => $event_info,
'session_key' => $this->_facebook->auth->getSessionKey()));
$actionLinks = json_encode($actionLinks);
}
- return $this->_facebook->call_method('facebook.feed.registerTemplateBundle',
+ return $this->_facebook->callMethod('facebook.feed.registerTemplateBundle',
array('one_line_story_templates' => $oneLineStory,
'short_story_templates' => $shortStory,
'full_story_template' => $fullStory,
*/
public function &getRegisteredTemplateBundles()
{
- return $this->_facebook->call_method('facebook.feed.getRegisteredTemplateBundles');
+ return $this->_facebook->callMethod('facebook.feed.getRegisteredTemplateBundles');
}
/**
*/
public function &getRegisteredTemplateBundleByID($id)
{
- return $this->_facebook->call_method('facebook.feed.getRegisteredTemplateBundleByID',
+ return $this->_facebook->callMethod('facebook.feed.getRegisteredTemplateBundleByID',
array('template_bundle_id' => $id));
}
*/
public function &deactivateTemplateBundleByID($id)
{
- return $this->_facebook->call_method('facebook.feed.deactivateTemplateBundleByID',
+ return $this->_facebook->callMethod('facebook.feed.deactivateTemplateBundleByID',
array('template_bundle_id' => $id));
}
$targetIds = trim($targetIds, "[]");
}
- return $this->_facebook->call_method('facebook.feed.publishUserAction',
+ return $this->_facebook->callMethod('facebook.feed.publishUserAction',
array('template_bundle_id' => $bundleId,
'template_data' => $data,
'target_ids' => $targetIds,
*/
public function &getAppFriendStories()
{
- return $this->_facebook->call_method('facebook.feed.getAppFriendStories');
+ return $this->_facebook->callMethod('facebook.feed.getAppFriendStories');
}
}
\ No newline at end of file
$params['session_key'] = $this->_facebook->auth->getSessionKey();
}
- return $this->_facebook->call_method('facebook.fql.query', $params);
+ return $this->_facebook->callMethod('facebook.fql.query', $params);
}
}
\ No newline at end of file
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('facebook.friends.areFriends',
+ return $this->_facebook->callMethod('facebook.friends.areFriends',
array('uids1' => $uids1,
'uids2' => $uids2,
'session_key' => $skey));
$params['flid'] = $flid;
}
- return $this->_facebook->call_method('facebook.friends.get', $params);
+ return $this->_facebook->callMethod('facebook.friends.get', $params);
}
/**
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('facebook.friends.getLists',
+ return $this->_facebook->callMethod('facebook.friends.getLists',
array('session_key' => $this->_facebook->auth->getSessionKey()));
}
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('facebook.groups.get',
+ return $this->_facebook->callMethod('facebook.groups.get',
array('uid' => $uid, 'gids' => $gids, 'session_key' => $skey));
}
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('facebook.groups.getMembers',
+ return $this->_facebook->callMethod('facebook.groups.getMembers',
array('gid' => $gid, 'session_key' => $skey));
}
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('links.get',
+ return $this->_facebook->callMethod('links.get',
array('uid' => $uid,
'limit' => $limit,
'link_ids' => json_encode($link_ids),
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('links.post',
+ return $this->_facebook->callMethod('links.post',
array('uid' => $uid,
'url' => $url,
'comment' => $comment,
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('notes.create',
+ return $this->_facebook->callMethod('notes.create',
array('uid' => $uid,
'title' => $title,
'content' => $content,
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('notes.delete',
+ return $this->_facebook->callMethod('notes.delete',
array('uid' => $uid,
'note_id' => $note_id,
'session_key' => $skey));
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('notes.edit',
+ return $this->_facebook->callMethod('notes.edit',
array('note_id' => $note_id,
'title' => $title,
'content' => $content,
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('notes.get',
+ return $this->_facebook->callMethod('notes.get',
array('session_key' => $skey,
'uid' => $uid,
'note_ids' => json_encode($note_ids)));
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('facebook.notifications.get',
+ return $this->_facebook->callMethod('facebook.notifications.get',
array('session_key' => $skey));
}
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->call_method('facebook.notifications.send',
+ return $this->callMethod('facebook.notifications.send',
array('to_ids' => $to_ids,
'notification' => $notification,
'type' => $type,
throw new Horde_Service_Facebook_Exception('session_key is required',
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->call_method('facebook.notifications.sendEmail',
+ return $this->callMethod('facebook.notifications.sendEmail',
array('recipients' => $recipients,
'subject' => $subject,
'text' => $text,
if ($this->_facebook->dataFormat == Horde_Service_Facebook::DATA_FORMAT_ARRAY) {
$oldFormat = $this->_facebook->setInternalFormat(Horde_Service_Facebook::DATA_FORMAT_XML);
}
- $results = $this->_facebook->call_method('facebook.photos.addTag', $params);
+ $results = $this->_facebook->callMethod('facebook.photos.addTag', $params);
if (!empty($oldFormat)) {
$this->_facebook->setInternalFormat($oldFormat);
}
if ($this->_facebook->dataFormat == Horde_Service_Facebook::DATA_FORMAT_ARRAY) {
$oldFormat = $this->_facebook->setInternalFormat(Horde_Service_Facebook::DATA_FORMAT_XML);
}
- $results = $this->_facebook->call_method('facebook.photos.createAlbum', $params);
+ $results = $this->_facebook->callMethod('facebook.photos.createAlbum', $params);
if (!empty($oldFormat)) {
$this->_facebook->setInternalFormat($oldFormat);
}
if ($this->_facebook->dataFormat == Horde_Service_Facebook::DATA_FORMAT_ARRAY) {
$oldFormat = $this->_facebook->setInternalFormat(Horde_Service_Facebook::DATA_FORMAT_XML);
}
- $results = $this->_facebook->call_method('facebook.photos.get', $params);
+ $results = $this->_facebook->callMethod('facebook.photos.get', $params);
if (!empty($oldFormat)) {
$this->_facebook->setInternalFormat($oldFormat);
if ($this->_facebook->dataFormat == Horde_Service_Facebook::DATA_FORMAT_ARRAY) {
$oldFormat = $this->_facebook->setInternalFormat(Horde_Service_Facebook::DATA_FORMAT_XML);
}
- $results = $this->_facebook->call_method('facebook.photos.getAlbums',
+ $results = $this->_facebook->callMethod('facebook.photos.getAlbums',
array('uid' => $uid,
'aids' => $aids,
'session_key' => $skey));
if ($this->_facebook->dataFormat == Horde_Service_Facebook::DATA_FORMAT_ARRAY) {
$oldFormat = $this->_facebook->setInternalFormat(Horde_Service_Facebook::DATA_FORMAT_XML);
}
- $results = $this->_facebook->call_method('facebook.photos.getTags', array('pids' => $pids, 'session_key' => $skey));
+ $results = $this->_facebook->callMethod('facebook.photos.getTags', array('pids' => $pids, 'session_key' => $skey));
if (!empty($oldFormat)) {
$this->_facebook->setInternalFormat($oldFormat);
}
}
$params['method'] = $method;
- $params['api_key'] = $this->_facebook->api_key;
+ $params['api_key'] = $this->_facebook->apiKey;
$params['call_id'] = microtime(true);
if ($params['call_id'] <= $this->_last_call_id) {
$params['call_id'] = $this->_last_call_id + 0.001;
*/
public function &getInfo($uids, $fields)
{
- return $this->_facebook->call_method('facebook.users.getInfo',
+ return $this->_facebook->callMethod('facebook.users.getInfo',
array('uids' => $uids,
'fields' => $fields,
'session_key' => $this->_sessionKey));
*/
public function &getStandardInfo($uids, $fields)
{
- return $this->_facebook->call_method('facebook.users.getStandardInfo',
+ return $this->_facebook->callMethod('facebook.users.getStandardInfo',
array('uids' => $uids, 'fields' => $fields));
}
Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
}
- return $this->_facebook->call_method('facebook.users.getLoggedInUser',
+ return $this->_facebook->callMethod('facebook.users.getLoggedInUser',
array('session_key' => $this->_facebook->auth->getSessionKey()));
}
$params['uid'] = $uid;
}
- return $this->_facebook->call_method('facebook.users.hasAppPermission', $params);
+ return $this->_facebook->callMethod('facebook.users.hasAppPermission', $params);
}
/**
Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
}
- return $this->_facebook->call_method('facebook.users.isAppUser', $params);
+ return $this->_facebook->callMethod('facebook.users.isAppUser', $params);
}
/**
Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY);
}
- return $this->call_method('facebook.users.isVerified', array('session_key' => $this->_facebook->auth->getSessionKey()));
+ return $this->callMethod('facebook.users.isVerified', array('session_key' => $this->_facebook->auth->getSessionKey()));
}
/**
$params['session_key'] = $skey;
}
- return $this->_facebook->call_method('facebook.users.setStatus', $params);
+ return $this->_facebook->callMethod('facebook.users.setStatus', $params);
}
}
\ No newline at end of file
'description' => $description,
'session_key' => $skey),
$file,
- Horde_Service_Facebook::get_facebook_url('api-video') . '/restserver.php');
+ Horde_Service_Facebook::getFacebookUrl('api-video') . '/restserver.php');
}
/**
Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED);
}
- return $this->_facebook->call_method('facebook.video.getUploadLimits',
+ return $this->_facebook->callMethod('facebook.video.getUploadLimits',
array('session_key' => $skey));
}