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


PHP Facebook::get_loggedin_user方法代码示例

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


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

示例1: authorize

 function authorize()
 {
     global $globals, $db;
     $fb = new Facebook($globals['facebook_key'], $globals['facebook_secret']);
     $fb->require_login();
     $fb_user = $fb->get_loggedin_user();
     if ($_GET['op'] != 'ok' || !$fb_user) {
         $this->user_return();
     }
     $user_details = $fb->api_client->users_getInfo($fb_user, array('uid', 'name', 'profile_url', 'pic_square'));
     $this->token = $user_details[0]['uid'];
     $this->secret = $user_details[0]['uid'];
     $this->uid = $user_details[0]['uid'];
     $this->username = preg_replace('/.+?\\/.*?([\\w\\.\\-_]+)$/', '$1', $user_details[0]['profile_url']);
     // Most Facebook users don't have a name, only profile number
     if (!$this->username || preg_match('/^\\d+$/', $this->username)) {
         // Create a name like a uri used in stories
         if (strlen($user_details[0]['name']) > 2) {
             $this->username = User::get_valid_username($user_details[0]['name']);
         } else {
             $this->username = 'fb' . $this->username;
         }
     }
     $db->transaction();
     if (!$this->user_exists()) {
         $this->url = $user_details[0]['profile_url'];
         $this->names = $user_details[0]['name'];
         $this->avatar = $user_details[0]['pic_square'];
         $this->store_user();
     }
     $this->store_auth();
     $db->commit();
     $this->user_login();
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:34,代码来源:fbconnect.php

示例2: Facebook

 function sessions_end()
 {
     require_once PATH_LIB . "facebook-platform/php/facebook.php";
     $FB = new Facebook('58e131b52928d145f2f6f42146c17feb', '2de88d50a8c3f51ab26b5bd239726a5e');
     //start a new instance of the facebook object
     $FB_UID = $FB->get_loggedin_user();
     print_r($FB->user);
 }
开发者ID:newism,项目名称:nsm.fb_connect.ee_addon,代码行数:8,代码来源:ext.nsm_facebook_ext.php

示例3: Facebook

 function __construct(User &$user)
 {
     if (!$user->facebook_user) {
         $facebook = new Facebook(FacebookConfig::kConsumerKey, FacebookConfig::kConsumerSecret);
         $facebook_user = $facebook->get_loggedin_user();
         if ($facebook_user) {
             $hasExtendedPermission = $facebook->api_client->call_method('facebook.users_hasAppPermission', array('ext_perm' => 'status_update', 'uid' => $facebook_user));
             if ($hasExtendedPermission) {
                 $this->isAuthorized = true;
                 $user->facebook_user = $facebook_user;
                 $user->save();
                 $this->authorized_user = $user->facebook_user;
             }
         }
     } else {
         $this->isAuthorized = true;
         $this->authorized_user = $user->facebook_user;
     }
 }
开发者ID:aventurella,项目名称:Galaxy,代码行数:19,代码来源:SettingsFacebook.php

示例4: Facebook

//
//
// Application: Wordans
// File: 'index.php'
//
//
require_once 'client/facebook.php';
$appapikey = 'e7bada22344a845c6e3984e391cae1db';
$appsecret = '9b9691bda0c8cb18ae6599710640ead4';
$facebook = new Facebook($appapikey, $appsecret);
//$profileId = $facebook->get_loggedin_user(); // If the user is logged in and looks at their own wordans app this is the way to get their profile id
$linkFromFBBanner = $_GET['linkFromFBBanner'];
//If the facebook user hasn't installed the wordans app we still want them to see it in a public canvas page
if ($linkFromFBBanner == 'true') {
    //public canvas page
    $user = $facebook->get_loggedin_user();
} else {
    //do a login and configuration or show them the app if they have already installed it
    $user = $facebook->require_login();
    $appcallbackurl = 'http://www.wordans.com/wordans_flash/facebook_callback';
    // catch the exception that gets thrown if the cookie has
    // an invalid session_key in it
    try {
        if (!$facebook->api_client->users_isAppAdded()) {
            $facebook->redirect($facebook->get_add_url());
        }
    } catch (Exception $ex) {
        // this will clear cookies for your application and
        // redirect them to a login prompt
        $facebook->set_user(null, null);
        $facebook->redirect($appcallbackurl);
开发者ID:ersandeepdh,项目名称:izishirt,代码行数:31,代码来源:index.php

示例5: sfc_register_metadata

function sfc_register_metadata($user_id)
{
    $options = get_option('sfc_options');
    include_once 'facebook-platform/facebook.php';
    $fb = new Facebook($options['api_key'], $options['app_secret']);
    $fbuid = $fb->get_loggedin_user();
    // this is a facebook user, get the info
    if ($fbuid) {
        $user_details = $fb->api_client->users_getInfo($fbuid, 'first_name, last_name, profile_url, about_me');
        if ($user_details) {
            $user['ID'] = $user_id;
            $user['user_url'] = $user_details[0]['profile_url'];
            wp_update_user($user);
            update_usermeta($user_id, 'fbuid', $fbuid);
            update_usermeta($user_id, 'first_name', $user_details[0]['first_name']);
            update_usermeta($user_id, 'last_name', $user_details[0]['last_name']);
            update_usermeta($user_id, 'description', $user_details[0]['about_me']);
        }
    }
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:20,代码来源:sfc-register.php

示例6: template

include_once ROOT_PATH . 'common.' . PHP_EXT;
includeLang('PUBLIC');
// Uniconfig changed...
include_once ROOT_PATH . 'includes/uni.config.inc.php';
$template = new template();
$template->set_index();
$page = request_var('page', '');
$mode = request_var('mode', '');
switch ($page) {
    case 'facebook':
        if ($CONF['fb_on'] == 0) {
            exit(header("Location: index.php"));
        }
        include_once ROOT_PATH . 'includes/libs/facebook/facebook.php';
        $fb = new Facebook($CONF['fb_apikey'], $CONF['fb_skey']);
        $fb_user = $fb->get_loggedin_user();
        if ($fb_user) {
            $login = $db->uniquequery("SELECT `id`, `username`, `dpath`, `authlevel`, `id_planet`, `banaday` FROM " . USERS . " WHERE `fb_id` = '" . $fb_user . "';");
            if (isset($login)) {
                if ($login['banaday'] <= time() && $login['banaday'] != '0') {
                    $db->query("UPDATE " . USERS . " SET `banaday` = '0', `bana` = '0' WHERE `id` = '" . $login['id'] . "';");
                }
                $SESSION = new Session();
                $SESSION->CreateSession($login['id'], $login['username'], $login['id_planet'], $login['authlevel'], $login['dpath']);
                redirectTo("game." . PHP_EXT . "?page=overview");
            } else {
                $USER_details = $fb->api_client->users_getInfo($fb_user, array('first_name', 'last_name', 'proxied_email', 'username', 'contact_email'));
                if (!empty($USER_details[0]['contact_email']) && ValidateAddress($USER_details[0]['contact_email'])) {
                    $UserMail = $USER_details[0]['contact_email'];
                } else {
                    redirectTo("index." . PHP_EXT);
开发者ID:sonicmaster,项目名称:RPG,代码行数:31,代码来源:index.php

示例7: sfc_comm_fill_in_fields

function sfc_comm_fill_in_fields($comment_post_ID)
{
    if (is_user_logged_in()) {
        return;
    }
    // do nothing to WP users
    $options = get_option('sfc_options');
    include_once 'facebook-platform/facebook.php';
    $fb = new Facebook($options['api_key'], $options['app_secret']);
    $fbuid = $fb->get_loggedin_user();
    // this is a facebook user, override the sent values with FB info
    if ($fbuid) {
        $user_details = $fb->api_client->users_getInfo($fbuid, 'name, profile_url');
        if (is_array($user_details)) {
            $_POST['author'] = $user_details[0]['name'];
            $_POST['url'] = $user_details[0]['profile_url'];
        }
        $query = "SELECT email FROM user WHERE uid=\"{$fbuid}\"";
        $email = $fb->api_client->fql_query($query);
        if (is_array($email)) {
            $email = $email[0]['email'];
            $_POST['email'] = $email;
        }
    }
}
开发者ID:thejimbirch,项目名称:unionrockyards,代码行数:25,代码来源:sfc-comments.php

示例8: Facebook

<?php

//Kill error reporting, just in case, must be on PHP 5
//found some erros in facebook-client/facebook.php that
//in some versions of PHP produce errors, but code will
//work on execution
ini_set("error_reporting", 0);
require_once 'facebook-client/facebook.php';
//our key and secret, create new Facebook api object
$appapikey = 'YOURKEY';
$appsecret = 'YOURSECRET';
$facebook = new Facebook($appapikey, $appsecret);
//This is the main variable that will store the facebook's user id
//important variable you can use throughout your application to reference
//facebook user id
$fb_uid = $facebook->get_loggedin_user();
//only change the exact text 'YOURKEY' with your key, you must leave on the _user
//ex $_COOKIE['208345uhoergu082h4r-92h8_user;]
$fb_user_cookie = $_COOKIE['YOURKEY_user'];
//very important*******
//try to grab facebook friends, if not then there is no user logged in, but cookie is still there
//kill any user cookie by set_user(NULL), this is important, because of facebooks
//cookies, you must set null if there was a recent login on browser.
try {
    $friends = $facebook->api_client->friends_get();
} catch (Exception $e) {
    $facebook->set_user(null, null);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
开发者ID:amanelis,项目名称:php-fbconnect,代码行数:31,代码来源:connect.php

示例9: sfc_get_user

function sfc_get_user()
{
    $options = get_option('sfc_options');
    include_once 'facebook-platform/facebook.php';
    $fb = new Facebook($options['api_key'], $options['app_secret']);
    $fbuid = $fb->get_loggedin_user();
    return $fbuid;
}
开发者ID:thejimbirch,项目名称:unionrockyards,代码行数:8,代码来源:sfc-base.php

示例10: sfc_login_logout

function sfc_login_logout()
{
    $options = get_option('sfc_options');
    // load facebook platform
    include_once 'facebook-platform/facebook.php';
    $fb = new Facebook($options['api_key'], $options['app_secret']);
    $fbuid = $fb->get_loggedin_user();
    if ($fbuid) {
        $fb->logout(wp_login_url() . '?loggedout=true');
    }
}
开发者ID:thejimbirch,项目名称:unionrockyards,代码行数:11,代码来源:sfc-login.php


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