当前位置: 首页>>代码示例>>PHP>>正文


PHP FacebookSession::getToken方法代码示例

本文整理汇总了PHP中Facebook\FacebookSession::getToken方法的典型用法代码示例。如果您正苦于以下问题:PHP FacebookSession::getToken方法的具体用法?PHP FacebookSession::getToken怎么用?PHP FacebookSession::getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook\FacebookSession的用法示例。


在下文中一共展示了FacebookSession::getToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeFQLQuery

 /**
  * Runs an FQL query and return its content
  *
  * @param String $query A valid FQL query
  * @param String $castAs Cast the result as a specialized GraphObject (GraphAlbum, GraphLocation, GraphUser)
  * @return GraphObject
  */
 public function executeFQLQuery($query, $castAs = NULL)
 {
     if ($castAs === NULL) {
         $castAs = GraphObject::className();
     }
     return (new FacebookRequest($this->facebookSession, 'GET', '/fql', ['access_token' => $this->facebookSession->getToken(), 'q' => $query]))->execute()->getGraphObject($castAs);
 }
开发者ID:zolli,项目名称:phacebook,代码行数:14,代码来源:Phacebook.php

示例2: facebook

 public function facebook()
 {
     $facebook_default_scope = explode(',', $this->ci->config->item("facebook_default_scope"));
     $facebook_app_id = $this->ci->config->item("facebook_app_id");
     $facebook_api_secret = $this->ci->config->item("facebook_api_secret");
     // init app with app id and secret
     FacebookSession::setDefaultApplication($facebook_app_id, $facebook_api_secret);
     // login helper with redirect_uri
     $helper = new FacebookRedirectLoginHelper(site_url('login/facebook'));
     // see if a existing session exists
     if (isset($_SESSION) && isset($_SESSION['fb_token'])) {
         // create new session from saved access_token
         $session = new FacebookSession($_SESSION['fb_token']);
         // validate the access_token to make sure it's still valid
         try {
             if (!$session->validate()) {
                 $session = null;
             }
         } catch (Exception $e) {
             // catch any exceptions
             $session = null;
         }
     }
     if (!isset($session) || $session === null) {
         // no session exists
         try {
             $session = $helper->getSessionFromRedirect();
         } catch (FacebookRequestException $ex) {
             // When Facebook returns an error
             // handle this better in production code
             print_r($ex);
         } catch (Exception $ex) {
             // When validation fails or other local issues
             // handle this better in production code
             print_r($ex);
         }
     }
     // see if we have a session
     if (isset($session)) {
         // save the session
         $_SESSION['fb_token'] = $session->getToken();
         // create a session using saved token or the new one we generated at login
         $session = new FacebookSession($session->getToken());
         // graph api request for user data
         //$request = new FacebookRequest($session, 'GET', '/me/friends');
         $request = new FacebookRequest($session, 'GET', '/me?fields=id,name,picture,friends');
         $response = $request->execute();
         // get response
         $graphObject = $response->getGraphObject()->asArray();
         $fb_data = array('me' => $graphObject, 'loginUrl' => $helper->getLoginUrl($facebook_default_scope));
         $this->ci->session->set_userdata('fb_data', $fb_data);
     } else {
         $fb_data = array('me' => null, 'loginUrl' => $helper->getLoginUrl($facebook_default_scope));
         $this->ci->session->set_userdata('fb_data', $fb_data);
     }
     return $fb_data;
 }
开发者ID:ponchov,项目名称:quizzworld,代码行数:57,代码来源:lib_login.php

示例3: connect

 /**
  * @param string $accessToken
  * @param string $appId
  * @param string $appSecret
  * @throws \Vegas\Social\Exception
  */
 protected function connect($accessToken, $appId, $appSecret)
 {
     $session = new FacebookSession($accessToken);
     $session->setDefaultApplication($appId, $appSecret);
     if ($session->getToken() == $accessToken) {
         $this->fbSession = $session;
         $this->fbScope = $session->getSessionInfo()->getScopes();
         $this->checkPermissions();
         return $this;
     }
     $this->fbSession = false;
     throw new \Vegas\Social\Exception\InvalidSessionException();
 }
开发者ID:vegas-cmf,项目名称:social,代码行数:19,代码来源:Service.php

示例4: allpost

 private function allpost()
 {
     $session = $this->getSession();
     $helper = $this->getHelper();
     if (isset($session)) {
         $_SESSION['fb_token'] = $session->getToken();
         $session = new FacebookSession($session->getToken());
         $request = new FacebookRequest($session, 'GET', '/me/feed');
         $response = $request->execute();
         //var_dump($response->getPageId());
         $graphObject = $response->getGraphObject()->asArray();
     }
     $data = json_decode(json_encode($graphObject), true);
     return $data;
 }
开发者ID:skrokbogumil,项目名称:KlientPoczty,代码行数:15,代码来源:ApiController.php

示例5: __construct

 public function __construct($app_id, $app_secret, $redirectURI)
 {
     FacebookSession::setDefaultApplication($app_id, $app_secret);
     $this->loginHelper = new FacebookRedirectLoginHelper($redirectURI);
     // see if a existing session exists
     if (isset($_SESSION) && isset($_SESSION['fb_token'])) {
         $session = new FacebookSession($_SESSION['fb_token']);
         // create new session from saved access_token
         // validate the access_token to make sure it's still valid
         try {
             if (!$session->validate()) {
                 $session = null;
             }
         } catch (Exception $e) {
             $session = null;
         }
     } else {
         // no session exists
         try {
             $session = $this->loginHelper->getSessionFromRedirect();
         } catch (FacebookRequestException $ex) {
             $session = null;
             var_dump($ex);
         } catch (Exception $ex) {
             $session = null;
             var_dump($ex);
         }
     }
     // see if we have a session
     if (isset($session)) {
         $_SESSION['fb_token'] = $session->getToken();
         // Save the token
         $session = new FacebookSession($session->getToken());
         // create a session using saved token or the new one we generated at login
     } else {
         $session = null;
     }
     $this->session = $session;
 }
开发者ID:rajbdilip,项目名称:treasherlocked,代码行数:39,代码来源:Facebook.php

示例6: catch

        // print_r($session);
    } catch (FacebookRequestException $ex) {
        print_r($ex);
    } catch (Exception $ex) {
        print_r($ex);
    }
}
$google_session_token = "";
// see if we have a session
if (isset($session)) {
    //echo "session cretaed _ ". $session;
    //require_once( 'libs/resize_image.php' );
    $_SESSION['fb_login_session'] = $session;
    $_SESSION['fb_token'] = $session->getToken();
    // create a session using saved token or the new one we generated at login
    $session = new FacebookSession($session->getToken());
    //print_r($session );
    $request_user_details = new FacebookRequest($session, 'GET', '/me?fields=id,name');
    $response_user_details = $request_user_details->execute();
    $user_details = $response_user_details->getGraphObject()->asArray();
    //print_r($session );
    $user_id = $user_details['id'];
    //$user_id = 1456168281369216;
    $user_name = $user_details['name'];
    if (isset($_SESSION['google_session_token'])) {
        $google_session_token = $_SESSION['google_session_token'];
    }
    ?>

				<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
					<div class="container">
开发者ID:arunavkda,项目名称:facebookchallenge,代码行数:31,代码来源:index.php

示例7: __construct

 /**
  * FacebookRequest - Returns a new request using the given session.  optional
  *   parameters hash will be sent with the request.  This object is
  *   immutable.
  *
  * @param FacebookSession $session
  * @param string $method
  * @param string $path
  * @param array|null $parameters
  * @param string|null $version
  * @param string|null $etag
  */
 public function __construct(FacebookSession $session, $method, $path, $parameters = null, $version = null, $etag = null)
 {
     $this->session = $session;
     $this->method = $method;
     $this->path = $path;
     if ($version) {
         $this->version = $version;
     } else {
         $this->version = static::GRAPH_API_VERSION;
     }
     $this->etag = $etag;
     $params = $parameters ?: array();
     if ($session && !isset($params['access_token'])) {
         $params['access_token'] = $session->getToken();
     }
     if (!isset($params['appsecret_proof']) && FacebookSession::useAppSecretProof()) {
         $params['appsecret_proof'] = $this->getAppSecretProof($params['access_token']);
     }
     $this->params = $params;
 }
开发者ID:lga37,项目名称:modelo,代码行数:32,代码来源:FacebookRequest.php

示例8: FacebookRedirectLoginHelper

$app_secret = '';
$redirect_url = 'http://packetcode.com/apps/fbloginlogout/';
//3.Initialize application, create helper object and get fb sess
FacebookSession::setDefaultApplication($app_id, $app_secret);
$helper = new FacebookRedirectLoginHelper($redirect_url);
$sess = $helper->getSessionFromRedirect();
//check if facebook session exists
if (isset($_SESSION['fb_token'])) {
    $sess = new FacebookSession($_SESSION['fb_token']);
}
//logout
$logout = 'http://packetcode.com/apps/newfblogin&logout=true';
//4. if fb sess exists echo name
if (isset($sess)) {
    //store the token in the php session
    $_SESSION['fb_token'] = $sess->getToken();
    //create request object,execute and capture response
    $request = new FacebookRequest($sess, 'GET', '/me');
    // from response get graph object
    $response = $request->execute();
    $graph = $response->getGraphObject(GraphUser::classname());
    // use graph object methods to get user details
    $name = $graph->getName();
    $id = $graph->getId();
    $image = 'https://graph.facebook.com/' . $id . '/picture?width=300';
    $email = $graph->getProperty('email');
    echo "hi {$name} <br>";
    echo "your email is {$email} <br><Br>";
    echo "<img src='{$image}' /><br><br>";
    echo "<a href='" . $logout . "'><button>Logout</button></a>";
} else {
开发者ID:Canyian,项目名称:fbloginlogout,代码行数:31,代码来源:index.php

示例9: testSessionToken

 public function testSessionToken()
 {
     $session = new FacebookSession(FacebookTestHelper::getAppToken());
     $this->assertEquals(FacebookTestHelper::getAppToken(), $session->getToken());
 }
开发者ID:sodacrackers,项目名称:washyacht,代码行数:5,代码来源:FacebookSessionTest.php

示例10: testSessionToken

 public function testSessionToken()
 {
     $session = new FacebookSession(FacebookTestCredentials::$appToken);
     $this->assertEquals(FacebookTestCredentials::$appToken, $session->getToken());
 }
开发者ID:jonathanbugs,项目名称:anselmi,代码行数:5,代码来源:FacebookSessionTest.php

示例11: getLogoutUrl

 /**
  * Returns the URL to send the user in order to log out of Facebook.
  *
  * @param FacebookSession $session The session that will be logged out
  * @param string $next The url Facebook should redirect the user to after
  *   a successful logout
  *
  * @return string
  */
 public function getLogoutUrl(FacebookSession $session, $next)
 {
     $params = array('next' => $next, 'access_token' => $session->getToken());
     return 'https://www.facebook.com/logout.php?' . http_build_query($params, null, '&amp;');
 }
开发者ID:andreasspak,项目名称:social-networks-api,代码行数:14,代码来源:FacebookRedirectLoginHelper.php

示例12: catch

    } catch (FacebookRequestException $ex) {
        // When Facebook returns an error
        // handle this better in production code
        print_r($ex);
    } catch (Exception $ex) {
        // When validation fails or other local issues
        // handle this better in production code
        print_r($ex);
    }
}
// see if we have a session
if (isset($session)) {
    // save the session
    $_SESSION['fb_token'] = $session->getToken();
    // create a session using saved token or the new one we generated at login
    $session = new FacebookSession($session->getToken());
    // graph api request for user data
    $request = new FacebookRequest($session, 'GET', '/me');
    $response = $request->execute();
    // get response
    $graphObject = $response->getGraphObject()->asArray();
    // print profile data
    echo '<pre>' . print_r($graphObject, 1) . '</pre>';
    echo '<pre>' . $session->getToken() . '</pre>';
    $user = $response->getGraphObject(GraphUser::className());
    $userId = $user->getId();
    echo $userId;
    // graph api request for user friends
    $request1 = new FacebookRequest($session, 'GET', '/me/friends');
    $response1 = $request1->execute();
    // get response
开发者ID:centaurustech,项目名称:TreeBox,代码行数:31,代码来源:fbtest.php

示例13: simplefbpost

 public function simplefbpost()
 {
     // init app with app id and secret
     FacebookSession::setDefaultApplication($this->facebook_app_id, $this->facebook_api_secret);
     // login helper with redirect_uri
     $helper = new FacebookRedirectLoginHelper(site_url('landing/index'));
     // see if a existing session exists
     if (isset($_SESSION) && isset($_SESSION['fb_token'])) {
         // create new session from saved access_token
         $session = new FacebookSession($_SESSION['fb_token']);
         // validate the access_token to make sure it's still valid
         try {
             if (!$session->validate()) {
                 $session = null;
             }
         } catch (Exception $e) {
             // catch any exceptions
             $session = null;
         }
     }
     if (!isset($session) || $session === null) {
         // no session exists
         try {
             $session = $helper->getSessionFromRedirect();
         } catch (FacebookRequestException $ex) {
             // When Facebook returns an error
             // handle this better in production code
             print_r($ex);
         } catch (Exception $ex) {
             // When validation fails or other local issues
             // handle this better in production code
             print_r($ex);
         }
     }
     if (isset($session)) {
         // save the session
         $_SESSION['fb_token'] = $session->getToken();
         // create a session using saved token or the new one we generated at login
         $session = new FacebookSession($session->getToken());
         try {
             // with this session I will post a message to my own timeline
             $request = new FacebookRequest($session, 'POST', '/me/feed', array('link' => 'www.purnimapro.com', 'message' => 'Complete IT Solutions'));
             $response = $request->execute();
             $graphObject = $response->getGraphObject();
             // the POST response object
             echo '<pre>' . print_r($graphObject, 1) . '</pre>';
             $msgid = $graphObject->getProperty('id');
         } catch (FacebookRequestException $e) {
             // show any error for this facebook request
             echo 'Facebook (post) request error: ' . $e->getMessage();
         }
         if (isset($msgid)) {
             // we only need to the sec. part of this ID
             $parts = explode('_', $msgid);
             try {
                 $request2 = new FacebookRequest($session, 'GET', '/' . $parts[1]);
                 $response2 = $request2->execute();
                 $graphObject2 = $response2->getGraphObject();
                 // the GET response object
                 echo '<pre>' . print_r($graphObject2, 1) . '</pre>';
             } catch (FacebookRequestException $e) {
                 // show any error for this facebook request
                 echo 'Facebook (get) request error: ' . $e->getMessage();
             }
         }
     } else {
         // we need to create a new session, provide a login link
         echo 'No session, please <a href="' . $helper->getLoginUrl(array('publish_actions')) . '">login</a>.';
     }
 }
开发者ID:arunmisra2273,项目名称:punu,代码行数:70,代码来源:Fbalib.php

示例14: header

if (isset($_GET['type']) && $_GET['type'] == 'facebook') {
    $fb_url = $helper->getLoginUrl(array('email'));
    header('Location: ' . $fb_url);
}
$session = $helper->getSessionFromRedirect();
if (isset($_SESSION['token'])) {
    $session = new FacebookSession($_SESSION['token']);
    try {
        $session->validate(FB_APP_ID, FB_APP_SECRET);
    } catch (FacebookAuthorizationException $e) {
        echo $e->getMessage();
    }
}
$data = array();
if (isset($session)) {
    $_SESSION['token'] = $session->getToken();
    $request = new FacebookRequest($session, 'GET', '/me');
    $response = $request->execute();
    $graph = $response->getGraphObject(GraphUser::className());
    $data = $graph->asArray();
    $id = $graph->getId();
    $image = "https://graph.facebook.com/" . $id . "/picture?width=100";
    $data['image'] = $image;
    if ($user_obj->fb_login($data)) {
        header('Location: home.php');
    } else {
        header('Location: index.php');
    }
}
/*********Facebook Login **********/
/*******Google ******/
开发者ID:Aravindumasankar,项目名称:b_b,代码行数:31,代码来源:login.php

示例15: setSession

 public function setSession(FacebookSession $session)
 {
     $this->setAccessToken($session->getToken());
     $this->session = $session;
 }
开发者ID:garyrutland,项目名称:yii2-facebook-sdk,代码行数:5,代码来源:Facebook.php


注:本文中的Facebook\FacebookSession::getToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。