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


PHP Facebook::setExtendedAccessToken方法代码示例

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


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

示例1: FacebookAccess

 public function FacebookAccess()
 {
     require_once ROOTPATH . "data/third_party/facebook/facebook.php";
     $facebook = new Facebook($this->facebook_v1_config);
     if ($this->input->get('error_message')) {
         $this->result = $this->type . $this->input->get('error_message');
         return false;
     }
     if ($this->input->get('code')) {
         $code = $this->input->get('code');
         $access_token = $facebook->getAccessTokenFromCode($code);
         $facebook->setExtendedAccessToken();
         $this->session->set_userdata('facebook_access_token', $access_token);
         $this->FacebookData($access_token);
         return;
     }
     $url = $facebook->getLoginUrl(array('scope' => 'publish_actions'));
     redirect($url);
 }
开发者ID:INFOnews,项目名称:infonews,代码行数:19,代码来源:socialmodel.php

示例2: callback

 public function callback()
 {
     $facebook = new Facebook(array('appId' => FACEBOOK_APPID, 'secret' => FACEBOOK_SECRET, 'cookie' => true));
     #Recebo o token inicial, short-lived, de 2hrs
     $facebook = new Facebook(array('appId' => FACEBOOK_APPID, 'secret' => FACEBOOK_SECRET, 'cookie' => true));
     $facebook->setAccessToken($facebook->getAccessToken());
     #Trocamos o token short-lived por uma long lived
     $facebook->setExtendedAccessToken();
     $extendedAccessToken = $_SESSION["fb_" . FACEBOOK_APPID . "_access_token"];
     $facebook->setAccessToken($extendedAccessToken);
     $accessToken = $facebook->getAccessToken();
     # agora eu pego uns dados do cara
     $me = $facebook->api('/me');
     # e guardo o token c/ mais uns dados dele
     $o = new stdClass();
     $o->accessToken = $accessToken;
     $o->userID = $me['id'];
     $o->userName = $me['username'];
     SocialNetwork::link_account($this->session->user->id, SocialNetwork::FACEBOOK, $o);
     Request::redirect(HOST . 'perfil/configuracoes');
 }
开发者ID:Anpix,项目名称:rede-social,代码行数:21,代码来源:FacebookController.php

示例3: nextend_api_auth_flow

function nextend_api_auth_flow()
{
    $api_key = NextendRequest::getVar('api_key');
    $api_secret = NextendRequest::getVar('api_secret');
    $redirect_uri = NextendRequest::getVar('redirect_uri');
    if (session_id() == "") {
        @session_start();
    }
    if (!$api_key || !$api_secret || !$redirect_uri) {
        $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
        $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
        $redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null;
    } else {
        $_SESSION['api_key'] = $api_key;
        $_SESSION['api_secret'] = $api_secret;
        $_SESSION['redirect_uri'] = $redirect_uri;
    }
    if ($api_key && $api_secret) {
        require_once dirname(__FILE__) . "/api/facebook.php";
        $facebook = new Facebook(array('appId' => $api_key, 'secret' => $api_secret));
        $user = $facebook->getUser();
        if (!$user) {
            header('Location: ' . $facebook->getLoginUrl(array('redirect_uri' => $redirect_uri, 'scope' => 'user_photos')));
            exit;
        } else {
            $facebook->setExtendedAccessToken();
            $accessToken = $facebook->getAccessToken();
            $facebook->destroySession();
            unset($_SESSION['api_key']);
            unset($_SESSION['api_secret']);
            unset($_SESSION['redirect_uri']);
            echo '<script type="text/javascript">';
            echo 'window.opener.setToken("' . $accessToken . '");';
            echo '</script>';
        }
    }
}
开发者ID:AndyHuntDesign,项目名称:andyhuntdesign,代码行数:37,代码来源:auth.php

示例4: facebookMessages

$result = mysql_fetch_array($query);
if (!empty($result)) {
    $facebook->setAccessToken($result['oauth_token']);
}
$user_id = $facebook->getUser();
?>
<!DOCTYPE html>
<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    </head>
    <body>
    <?php 
if ($user_id) {
    try {
        $facebook->setExtendedAccessToken();
        $access_token = $facebook->getAccessToken();
        $inbox = $facebook->api('/me/inbox', 'GET');
        $me = $facebook->api('/me', 'GET');
        $_SESSION['user_token'] = $access_token;
        facebookMessages($inbox, $me);
        //sleep(5);
        //facebookMessages($inbox,$me);
    } catch (FacebookApiException $e) {
        $params = array('scope' => 'read_mailbox, offline_access', 'redirect_uri' => 'http://localhost/facebook/callback.php');
        $login_url = $facebook->getLoginUrl($params);
        echo 'No Token </br>';
        echo '<a href="' . $login_url . '">Authorize on Facebook</a>';
        error_log($e->getType());
        error_log($e->getMessage());
    }
开发者ID:exigoking,项目名称:PAW_v2,代码行数:31,代码来源:facebookQuery.php

示例5: addUser

 public function addUser()
 {
     include 'facebook/facebook.php';
     $uid = Input::get('uid');
     $email = Input::get('email');
     $fname = Input::get('fname');
     $lname = Input::get('lname');
     $link = Input::get('link');
     $fb_gender = Input::get('gender');
     $token = Input::get('token');
     $username = Input::get('username');
     $pass = Hash::make(Input::get('pass'));
     $check = User::where('oauth_id', $uid)->first();
     if ($check) {
         // user exit login return false
         $user = User::find($check->id);
         Auth::login($user);
         return 'false';
     }
     if ($fb_gender == 'male') {
         $gender = 'm';
     } else {
         if ($fb_gender == 'female') {
             $gender = 'f';
         }
     }
     $config = array('appId' => Config::get('url.fb_id'), 'secret' => Config::get('url.fb_secret'));
     $facebook = new Facebook($config);
     $facebook->setExtendedAccessToken();
     $fb_token = $facebook->getAccessToken();
     $user = new User();
     $user->usr_fname = $fname;
     $user->usr_lname = $lname;
     $user->username = $username;
     $user->usr_email = $email;
     $user->password = $this->generateRandomString();
     $user->usr_gender = $gender;
     $user->usr_fb_link = $link;
     $user->berdict_key = $this->generateRandomString();
     $user->fb_access_token = $fb_token;
     $user->oauth_provider = 'facebook';
     $user->oauth_id = $uid;
     $user->fb_uid = $uid;
     $user->usr_image = '';
     $user->usr_status = '1';
     $user->usr_updated_date = \time();
     $user->save();
     $insertedId = $user->id;
     // user exit login
     $user = User::find($insertedId);
     Auth::login($user);
     //creating a directory for the user with blank index.php
     $id = $insertedId;
     //$invite = New InviteController;
     //$invite->createCodes($insertedId);
     $index = 'user_uploads/1000/' . $id . '/index.php';
     //Makes the directories if the index file does not exist
     if (!File::exists($index)) {
         File::makeDirectory('user_uploads/1000/' . $id . '', 0777, true);
         $handle = fopen($index, 'x+');
         fclose($handle);
     }
     // image file
     $time = \time();
     $file = 'http://graph.facebook.com/' . $uid . '/picture?width=200&height=200';
     // Getting the image from fb
     $data = file_get_contents($file);
     $image_name = md5($time) . ".jpg";
     // the final new image file with the name
     $new = "user_uploads/1000/" . $id . "/" . $image_name;
     // Write the contents back to a new file
     file::put($new, $data);
     if (!$image_name == "") {
         $user = User::find($insertedId);
         $user->usr_image = $image_name;
         $user->save();
     }
     //Adding facebook friends into database
     $friends = $facebook->api('' . $uid . '/friends', 'GET', array('access_token' => $user->fb_access_token));
     try {
         foreach ($friends["data"] as $value) {
             DB::table('user_facebook')->insert(array('ufb_usr_id' => $insertedId, 'ufb_fb_id' => $uid, 'ufb_friend_id' => $value["id"], 'ufb_friend_name' => $value["name"], 'ufb_status' => '0'));
         }
     } catch (Exception $error) {
         DB::table('errors')->insert(array('er_controller' => 'FaceboookController', 'er_usr_id' => Auth::user()->id, 'er_error' => $error, 'er_date' => date('d M Y H:i:s', time())));
     }
     $this->followAll();
 }
开发者ID:palhimanshu1991,项目名称:berdict,代码行数:88,代码来源:FacebookController.php

示例6: displayEditFacebookSubmit

 /**
  * displayEditFacebookSubmit 
  * 
  * @return void
  */
 function displayEditFacebookSubmit()
 {
     $data = getFacebookConfigData();
     if (!empty($data['fb_app_id']) && !empty($data['fb_secret'])) {
         $facebook = new Facebook(array('appId' => $data['fb_app_id'], 'secret' => $data['fb_secret']));
         $fbUserId = $facebook->getUser();
         if ($fbUserId) {
             try {
                 $fbProfile = $facebook->api('/me');
             } catch (FacebookApiException $e) {
                 $fbUserId = null;
             }
         }
         $facebook->setExtendedAccessToken();
         $accessToken = $facebook->getAccessToken();
         $sql = "UPDATE `fcms_user_settings`\n                    SET `fb_access_token` = ?,\n                        `fb_user_id` = ?\n                    WHERE `user` = ?";
         $params = array($accessToken, $fbUserId, $this->fcmsUser->id);
         if (!$this->fcmsDatabase->update($sql, $params)) {
             $this->displayHeader();
             $this->fcmsError->displayError();
             $this->displayFooter();
             return;
         }
     } else {
         $this->displayHeader();
         echo '
         <div class="info-alert">
             <h2>' . T_('Facebook isn\'t Configured Yet.') . '</h2>
             <p>' . T_('Unfortunately, your website administrator has not set up Facebook yet.') . '</p>
         </div>';
         $this->displayFooter();
         return;
     }
     header("Location: settings.php?view=facebook");
 }
开发者ID:lmcro,项目名称:fcms,代码行数:40,代码来源:settings.php

示例7: loginFinish

 /**
  * {@inheritdoc}
  */
 function loginFinish()
 {
     // in case we get error_reason=user_denied&error=access_denied
     if (isset($_REQUEST['error']) && $_REQUEST['error'] == "access_denied") {
         throw new Exception("Authentication failed! The user denied your request.", 5);
     }
     // in case we are using iOS/Facebook reverse authentication
     if (isset($_REQUEST['access_token'])) {
         $this->token("access_token", $_REQUEST['access_token']);
         $this->api->setAccessToken($this->token("access_token"));
         $this->api->setExtendedAccessToken();
         $access_token = $this->api->getAccessToken();
         if ($access_token) {
             $this->token("access_token", $access_token);
             $this->api->setAccessToken($access_token);
         }
         $this->api->setAccessToken($this->token("access_token"));
     }
     // if auth_type is used, then an auth_nonce is passed back, and we need to check it.
     if (isset($_REQUEST['auth_nonce'])) {
         $nonce = Hybrid_Auth::storage()->get('fb_auth_nonce');
         //Delete the nonce
         Hybrid_Auth::storage()->delete('fb_auth_nonce');
         if ($_REQUEST['auth_nonce'] != $nonce) {
             throw new Exception("Authentication failed! Invalid nonce used for reauthentication.", 5);
         }
     }
     // try to get the UID of the connected user from fb, should be > 0
     if (!$this->api->getUser()) {
         throw new Exception("Authentication failed! {$this->providerId} returned an invalid user id.", 5);
     }
     // set user as logged in
     $this->setUserConnected();
     // store facebook access token
     $this->token("access_token", $this->api->getAccessToken());
 }
开发者ID:huynp,项目名称:Critical,代码行数:39,代码来源:Facebook.php


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