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


PHP Facebook::getAccessToken方法代码示例

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


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

示例1: __get

 public function __get($name)
 {
     if ($name == "value") {
         if ($this->fb->getUser()) {
             $this->value = $this->fb->getAccessToken();
         } else {
             $this->value = "NONE";
         }
         return $this->value;
     } else {
         return parent::__get($name);
     }
 }
开发者ID:SheffieldWalkingGroup,项目名称:swgwebsite,代码行数:13,代码来源:facebooklogin.php

示例2: saveProfileSystemInfo

    /**
     * save social information
     * access token,
     */
    public function saveProfileSystemInfo()
    {
        if ($oProfile = self::getProfileObject()) {
            $sSocialID = (string) $oProfile->id;
            $session = serialize(self::$object->getAccessToken());
            $profileInfo = serialize($oProfile);
            if ($sSocialID && $session && $profileInfo) {
                return SJB_DB::query('INSERT INTO `facebook` SET `facebook_id` = ?s, `access` = ?s, `profile_info` = ?s
					ON DUPLICATE KEY UPDATE `access` = ?s, `profile_info`=?s', $sSocialID, $session, $profileInfo, $session, $profileInfo);
            }
            return false;
        }
        return null;
    }
开发者ID:Maxlander,项目名称:shixi,代码行数:18,代码来源:facebook_social_plugin.php

示例3: login

 /**
  * Log a user in
  * @return Array Userdata
  * @throws FacebookApiException
  */
 public function login($grabUserImage = false)
 {
     $uid = $this->_client->getUser();
     $accessToken = $this->_client->getAccessToken();
     // If a user is authenticated, $userData will be filled with user data
     $userData = $this->_client->api('/me');
     if ($grabUserImage) {
         $apiUrl = '/' . $this->_client->getUser() . '/picture?redirect=0&type=large';
         $picture = $this->_client->api($apiUrl);
         $userData['imageUrl'] = $picture['data']['url'];
     }
     $userData['access_token'] = $accessToken;
     return $userData;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:19,代码来源:Facebook.php

示例4: callback

 public function callback()
 {
     $member = Member::currentUser();
     if ($member) {
         $SiteConfig = SiteConfig::current_site_config();
         $request = $this->getRequest()->requestVars();
         $facebook = new Facebook(array('appId' => $SiteConfig->FBAppID, 'secret' => $SiteConfig->FBSecret, 'code' => $request['code']));
         $facebook->setAccessToken($facebook->getAccessToken());
         if ($facebook->getUser() && $facebook->getAccessToken()) {
             $SiteConfig->FBVerified = $facebook->getAccessToken();
         }
         $SiteConfig->write();
         $this->redirect('/admin/settings');
     }
 }
开发者ID:helpfulrobot,项目名称:firesphere-social,代码行数:15,代码来源:FacebookController.php

示例5: testSetSession

 public function testSetSession()
 {
     $facebook = new Facebook(array('appId' => self::APP_ID, 'secret' => self::SECRET, 'cookie' => true));
     $facebook->setSession(self::$VALID_EXPIRED_SESSION);
     $this->assertTrue($facebook->getUser() == self::$VALID_EXPIRED_SESSION['uid'], 'Expect uid back.');
     $this->assertTrue($facebook->getAccessToken() == self::$VALID_EXPIRED_SESSION['access_token'], 'Expect access token back.');
 }
开发者ID:Rockozer,项目名称:php-sdk,代码行数:7,代码来源:tests.php

示例6: Facebook

 function try_connect($pubit = 0, $stUrl = '', $PublishMessage = '')
 {
     $myparams =& JComponentHelper::getParams('com_fbjconnect');
     $getappid = $myparams->get('appid');
     $getappsec = $myparams->get('appsecret');
     $access_token = "";
     $uid = "";
     $postresult = false;
     $facebook = new Facebook(array('appId' => $getappid, 'secret' => $getappsec, 'cookie' => true));
     $session = $facebook->getSession();
     $me = null;
     $uid = "";
     if ($session) {
         try {
             $access_token = $facebook->getAccessToken();
             $me = $facebook->api('/me');
             $uid = $facebook->getUser();
             if ($pubit == 1) {
                 $fbpic = JURI::base() . 'modules/mod_jfbgconnect/fgimage.jpg';
                 $postresult = $facebook->api('/me/feed/', 'post', array('access_token' => $access_token, 'picture' => $fbpic, 'link' => $stUrl, 'message' => $PublishMessage));
             }
         } catch (FacebookApiException $e) {
             error_log($e);
         }
     }
     return array($uid, $me, $session, $access_token, $postresult);
 }
开发者ID:akksi,项目名称:jcg,代码行数:27,代码来源:fbgccontroller.php

示例7: doLogin

 public function doLogin()
 {
     $code = Input::get('code');
     if (strlen($code) == 0) {
         return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');
     }
     $facebook = new Facebook(Config::get('facebook'));
     $uid = $facebook->getUser();
     if ($uid == 0) {
         return Redirect::to('/')->with('message', 'There was an error');
     }
     $me = $facebook->api('/me', ['fields' => ['id', 'first_name', 'last_name', 'picture', 'email', 'gender']]);
     $profile = Profile::whereUid($uid)->first();
     if (empty($profile)) {
         $user = new User();
         $user->name = $me['first_name'] . ' ' . $me['last_name'];
         $user->email = $me['email'];
         $user->photo = 'https://graph.facebook.com/' . $me['id'] . '/picture?type=large';
         $user->save();
         $profile = new Profile();
         $profile->uid = $uid;
         $profile->username = $me['id'];
         $profile->gender = $me['gender'];
         $profile = $user->profiles()->save($profile);
     }
     $profile->access_token = $facebook->getAccessToken();
     $profile->save();
     $user = $profile->user;
     Auth::login($user);
     return Redirect::to('/')->with('message', 'Logged in with Facebook');
 }
开发者ID:talha08,项目名称:Login-With-Facebook,代码行数:31,代码来源:FacebookController.php

示例8: authenticate

 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     $user = $this->_Collection->Auth->user();
     $service = strtolower($request->params['pass'][0]);
     if ($service !== $this->service) {
         return false;
     }
     try {
         $facebook = new Facebook(array('appId' => $this->myConsumerKey, 'secret' => $this->myConsumerSec, 'cookie' => true));
         $action = $request->params['action'];
         if ($action === 'login') {
             $url = $facebook->getLoginUrl(array('redirect_uri' => Router::url('callback/facebook/', true), 'scope' => 'email,publish_stream'));
             if ($url !== null) {
                 $response->header('Location', $url);
                 $response->send();
             }
         } elseif ($action === 'callback') {
             preg_match('/state=(.*)/', $_REQUEST['url'], $state);
             $_REQUEST['state'] = $state[1];
             $accessToken = $facebook->getAccessToken();
             if ($accessToken != '') {
                 $this->_fetch($facebook, $accessToken, $response);
             } else {
                 //you should throw exception
             }
         }
     } catch (OAuthException $E) {
         //you can catch OAuth exception
     }
 }
开发者ID:noahm,项目名称:cakephp-FacebookAuthenticate,代码行数:30,代码来源:FacebookAuthenticate.php

示例9: mx_mntestusers

function mx_mntestusers($page, $option, $action)
{
    global $facebook;
    echo 'Disabled.';
    return;
    $fbapp = new Facebook(array('appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET, 'grant_type' => 'client_credentials'));
    $acctok = $fbapp->getAccessToken();
    if ($_REQUEST['createuser']) {
        $newuser = $fbapp->api('/' . FACEBOOK_APP_ID . '/accounts/test-users?installed=true&permissions=&access_token=' . $acctok, 'POST');
    } else {
        if ($_REQUEST['deleteuser']) {
            foreach ($_REQUEST['selected'] as $user) {
                $testusers = $fbapp->api('/' . $user . '?access_token=' . $acctok, 'DELETE');
                mx_deleteuser($user);
                // delete should only be possible for test users!!
            }
        }
    }
    $testusers = $fbapp->api('/' . FACEBOOK_APP_ID . '/accounts/test-users&access_token=' . $acctok, 'GET');
    echo '<form action="' . mx_optionurl($page, $option) . '" method=POST>';
    echo '<table border=1 width=100%><tr><th>Sel</th><th>ID</th><!-- <th>access_token</th> --><th>login_url</th></tr>';
    foreach ($testusers['data'] as $testuser) {
        echo '<tr><td><input type=checkbox name="selected[]" value="' . $testuser['id'] . '"></td>' . '<td>' . $testuser['id'] . '</td>';
        //$user=$facebook->api('/'.$testuser['id']);
        //die(print_r($user));
        //echo '<td>'.$user['name'].'</td>';
        echo '<!-- <td>' . $testuser['access_token'] . '</td> --><td>' . '<a href="' . $testuser['login_url'] . '">' . $testuser['login_url'] . '</a></td></tr>';
    }
    echo '<tr><td colspan=3 align=center><input type=submit name="createuser" value="Create User">' . ' <input type=submit name="deleteuser" value="Delete User(s)"></td></tr>';
    echo '</table></form>';
}
开发者ID:nsystem1,项目名称:OS-MusXpand,代码行数:31,代码来源:mx_admin.php

示例10: getAccessToken

 /**
  * Overrides Facebook's SDK call to pass it our defined Token and not
  * from a session.
  *
  * Returns regular SDK call if none set
  *
  * @return string
  */
 public function getAccessToken()
 {
     if ($this->accessToken !== null) {
         return $this->accessToken;
     } else {
         return parent::getAccessToken();
     }
 }
开发者ID:rdohms,项目名称:facebook-testuser-manager,代码行数:16,代码来源:Client.php

示例11: _connectCallback

 protected function _connectCallback()
 {
     $helper = Mage::helper('social/facebook');
     $storeId = Mage::app()->getStore()->getStoreId();
     $websiteId = Mage::app()->getStore()->getWebsiteId();
     $facebook = new Facebook(array('appId' => $helper->getFacebookConfig('client_id', $storeId), 'secret' => $helper->getFacebookConfig('client_secret', $storeId)));
     $fid = $facebook->getUser();
     $ftoken = $facebook->getAccessToken();
     if ($fid) {
         try {
             $data = $facebook->api('/me');
             $customersByFacebookId = Mage::helper('social/facebook')->getCustomersByFacebookId($fid, $websiteId);
             if (Mage::getSingleton('customer/session')->isLoggedIn()) {
                 if ($customersByFacebookId->getSize()) {
                     Mage::getSingleton('core/session')->addNotice($this->__('Your facebook account is already connected to one of our store accounts.'));
                     return $this;
                 }
                 $customer = Mage::getSingleton('customer/session')->getCustomer();
                 Mage::helper('social/facebook')->connectByFacebookId($customer, $fid, $ftoken);
                 Mage::getSingleton('core/session')->addSuccess($this->__('Your facebook account is now connected to your store account. You can now login using our facebook login button or using store account credentials you will receive to your email address.'));
                 return $this;
             }
             if ($customersByFacebookId->getSize()) {
                 $customer = $customersByFacebookId->getFirstItem();
                 Mage::helper('social/facebook')->loginByCustomer($customer);
                 Mage::getSingleton('core/session')->addSuccess($this->__('You have successfully logged in using your facebook account.'));
                 return $this;
             }
             $customersByEmail = Mage::helper('social/facebook')->getCustomersByEmail($data['email'], $websiteId);
             if ($customersByEmail->getSize()) {
                 $customer = $customersByEmail->getFirstItem();
                 Mage::helper('social/facebook')->connectByFacebookId($customer, $fid, $ftoken);
                 Mage::getSingleton('core/session')->addSuccess($this->__('We have discovered you already have an account at our store. Your facebook account is now connected to your store account.'));
                 return $this;
             }
             $firstName = $data['first_name'];
             if (empty($firstName)) {
                 throw new Exception($this->__('Sorry, could not retrieve your facebook first name. Please try again.'));
             }
             $lastName = $data['last_name'];
             if (empty($lastName)) {
                 throw new Exception($this->__('Sorry, could not retrieve your facebook last name. Please try again.'));
             }
             Mage::helper('social/facebook')->connectByCreatingAccount($data['email'], $data['first_name'], $data['last_name'], $fid, $ftoken);
             Mage::getSingleton('core/session')->addSuccess($this->__('Your facebook account is now connected to your new user account at our store. Now you can login using our facebook login button or using store account credentials you will receive to your email address.'));
             return $this;
         } catch (Exception $e) {
             Mage::getSingleton('core/session')->addError($this->__($e->getMessage()));
             return $this;
         }
     } else {
         Mage::getSingleton('core/session')->addError($this->__('Sorry, could not login. Please try again.'));
         return $this;
     }
 }
开发者ID:ramantalkin,项目名称:tmp01skin,代码行数:55,代码来源:FacebookController.php

示例12: 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

示例13: initialize

 function initialize(&$controller, $settings = array())
 {
     global $signed_request;
     $facebook = new Facebook(array('appId' => Configure::read('fbconfig.id'), 'secret' => Configure::read('fbconfig.secret'), 'cookie' => true));
     $access_token = $facebook->getAccessToken();
     if (isset($_REQUEST['signed_request'])) {
         // faster
         $signed_request = $_REQUEST['signed_request'];
     } else {
         // backup via API
         $signed_request = $facebook->getSignedRequest();
     }
     $this->facebook = $facebook;
 }
开发者ID:not-kierans-main-account,项目名称:PHP-test,代码行数:14,代码来源:FacebookComponent.php

示例14: fb_send

function fb_send($appid, $appsecret, $userid, $msg)
{
    try {
        $facebook = new Facebook(array('appId' => $appid, 'secret' => $appsecret, 'cookie' => true));
        $token = $facebook->getAccessToken();
        $post = array('access_token' => $token, 'message' => $msg);
        $res = $facebook->api('/' . $userid . '/feed', 'POST', $post);
        // echo post was sent successfully
        //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>New post was sent to Facebook');
    } catch (Exception $e) {
        // save error
        //em_save_post_error($id, $_SESSION['user'], $e->getMessage());
        // echo the error message
        //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>Facebook error:'.$e->getMessage());
    }
}
开发者ID:bobrock,项目名称:vesuvius,代码行数:16,代码来源:fb_send.php

示例15: actionFacebook

 public function actionFacebook()
 {
     Yii::import('application.vendors.Facebook.*');
     include_once 'facebook.php';
     $facebook = new Facebook(array('appId' => '274957429359215', 'secret' => '2f021bff5939f3ffe097b5e29a1baec4'));
     $params = array('scope' => 'public_profile, email, user_birthday, user_hometown', 'redirect_uri' => Yii::app()->request->hostInfo . Yii::app()->request->url);
     $loginUrl = $facebook->getLoginUrl($params);
     if ($user = $facebook->getUser()) {
         $authkey = $this->registrar_por_red_social('facebook', $facebook->getAccessToken());
         Yii::app()->session['key'] = $authkey;
         $this->redirect(array('/usuario/registro/crearclave'));
     } elseif ($_GET['error']) {
         Yii::app()->user->setFlash('error', "No se autorizó el registro con Facebook");
         $this->redirect(array('/usuario/registro'));
     } else {
         $this->redirect($loginUrl);
     }
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:18,代码来源:RegistroController.php


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