Services_Facebook
[ class tree: Services_Facebook ] [ index: Services_Facebook ] [ all elements ]

Source for file Auth.php

Documentation is available at Auth.php

  1. <?php
  2.  
  3. /**
  4.  * PHP5 interface for Facebook's REST API
  5.  *
  6.  * PHP version 5.1.0+
  7.  *
  8.  * LICENSE: This source file is subject to the New BSD license that is
  9.  * available through the world-wide-web at the following URI:
  10.  * http://www.opensource.org/licenses/bsd-license.php. If you did not receive
  11.  * a copy of the New BSD License and are unable to obtain it through the web,
  12.  * please send a note to license@php.net so we can mail you a copy immediately.
  13.  *
  14.  * @category  Services
  15.  * @package   Services_Facebook
  16.  * @author    Joe Stump <joe@joestump.net>
  17.  * @copyright 2007-2008 Joe Stump <joe@joestump.net>
  18.  * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
  19.  * @version   Release: 0.2.14
  20.  * @link      http://pear.php.net/package/Services_Facebook
  21.  */
  22.  
  23. require_once 'Services/Facebook/Common.php';
  24.  
  25. /**
  26.  * Facebook Authentication Interface
  27.  *
  28.  * <code>
  29.  * <?php
  30.  * require_once 'Services/Facebook.php';
  31.  * $api = Services_Facebook();
  32.  * // An instance of SimpleXmlElement with the response loaded into it
  33.  * // is returned.
  34.  * $session = $api->auth->getSession($_GET['auth_token']);
  35.  * echo 'uid: ' . (string)$session->uid . '<br />';
  36.  * echo 'session_key: ' . (string)$session->session_key . '<br />';
  37.  * ?>
  38.  * </code>
  39.  *
  40.  * @category Services
  41.  * @package  Services_Facebook
  42.  * @author   Joe Stump <joe@joestump.net>
  43.  * @author   Jeff Hodsdon <jeff@digg.com>
  44.  * @license  http://www.opensource.org/licenses/bsd-license.php New BSD License
  45.  * @version  Release: 0.2.14
  46.  * @link     http://wiki.developers.facebook.com
  47.  */
  48. {
  49.     /**
  50.      * Create a token for login
  51.      *
  52.      * @return string 
  53.      */
  54.     public function createToken()
  55.     {
  56.         $result $this->callMethod('auth.createToken');
  57.         return (string)$result;
  58.     }
  59.  
  60.     /**
  61.      * Convert auth_token into a session_key
  62.      *
  63.      * @param string $authToken auth_token from callback
  64.      *
  65.      * @return object SimpleXmlElement of response
  66.      */
  67.     public function getSession($authToken)
  68.     {
  69.         return $this->callMethod('auth.getSession'array(
  70.             'auth_token' => $authToken
  71.         ));
  72.     }
  73.  
  74.     /**
  75.      * Promote session
  76.      * 
  77.      * Creates a temporary session secret for the current (non-infinite)
  78.      * session of a Web application. This session secret will not be used in
  79.      * the signature for the server-side component of an application, it is
  80.      * only meant for use by the application which additionally want to use
  81.      * a client side component. (e.g. Javascript Client Library)
  82.      *
  83.      * @access public
  84.      * @return void 
  85.      */
  86.     public function promoteSession()
  87.     {
  88.         $result = (string) $this->callMethod('auth.promoteSession');
  89.         return $result;
  90.     }
  91.  
  92.     /**
  93.      * Expire session
  94.      * 
  95.      * Invalidates the current session being used, regardless of whether it
  96.      * is temporary or infinite. After successfully calling this function, no
  97.      * further API calls requiring a session will succeed using this session.
  98.      * If the invalidation is successful, this will return true.
  99.      *
  100.      * @access public
  101.      * @return void 
  102.      */
  103.     public function expireSession()
  104.     {
  105.         $result $this->callMethod('auth.expireSession');
  106.         return (intval((string) $result== 1);
  107.     }
  108.  
  109.     /**
  110.      * Revoke authorization
  111.      * 
  112.      * If this method is called for the logged in user, then no further API
  113.      * calls can be made on that user's behalf until the user decides to
  114.      * authorize the application again.
  115.      *
  116.      * @param string $uid User's id
  117.      *
  118.      * @access public
  119.      * @return void 
  120.      */
  121.     public function revokeAuthorization($uid = null)
  122.     {
  123.         $args = array();
  124.         if (isset($this->sessionKey)) {
  125.             $args['session_key'$this->sessionKey;
  126.         }
  127.  
  128.         if ($uid !== null{
  129.             $args['uid'$uid;
  130.         }
  131.  
  132.         $result $this->callMethod('auth.revokeAuthorization'$args);
  133.         return (intval($result== 1);
  134.     }
  135. }
  136.  
  137. ?>

Documentation generated on Thu, 01 Apr 2010 01:00:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.