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


PHP Facebook::require_login方法代码示例

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


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

示例1: authenticate

 /**
  * Log-in using Facebook cronus
  *
  * @param array &$state  Information about the current authentication.
  */
 public function authenticate(&$state)
 {
     assert('is_array($state)');
     /* We are going to need the authId in order to retrieve this authentication source later. */
     $state[self::AUTHID] = $this->authId;
     $stateID = SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT);
     SimpleSAML_Logger::debug('facebook auth state id = ' . $stateID);
     $facebook = new Facebook($this->api_key, $this->secret);
     $u = $facebook->require_login(SimpleSAML_Module::getModuleUrl('authfacebook') . '/linkback.php?next=' . $stateID);
     # http://developers.facebook.com/documentation.php?v=1.0&method=users.getInfo
     /* Causes an notice / warning...
     		if ($facebook->api_client->error_code) {
     			throw new Exception('Unable to load profile from facebook');
     		}
     		*/
     // http://developers.facebook.com/docs/reference/rest/users.getInfo
     $info = $facebook->api_client->users_getInfo($u, array('uid', 'first_name', 'middle_name', 'last_name', 'name', 'locale', 'current_location', 'affiliations', 'pic_square', 'profile_url', 'sex', 'email', 'pic', 'username', 'about_me', 'status', 'profile_blurb'));
     $attributes = array();
     foreach ($info[0] as $key => $value) {
         if (is_string($value) && !empty($value)) {
             $attributes['facebook.' . $key] = array((string) $value);
         }
     }
     if (array_key_exists('username', $info[0])) {
         $attributes['facebook_user'] = array($info[0]['username'] . '@facebook.com');
     } else {
         $attributes['facebook_user'] = array($u . '@facebook.com');
     }
     $attributes['facebook_targetedID'] = array('http://facebook.com!' . $u);
     $attributes['facebook_cn'] = array($info[0]['name']);
     SimpleSAML_Logger::debug('Facebook Returned Attributes: ' . implode(", ", array_keys($attributes)));
     $state['Attributes'] = $attributes;
 }
开发者ID:hpgihan,项目名称:cronus,代码行数:38,代码来源:Facebook.php

示例2: requireAuthenticate

 static function requireAuthenticate($is_ajax = true, $extra_secure = true, &$realUser = null)
 {
     global $api_key, $api_key_secret, $adminUserIDs;
     $u = MyAuth::checkAuthentication($extra_secure);
     if (!$u) {
         if ($is_ajax) {
             return 0;
         }
         $facebook = new Facebook($api_key, $api_key_secret);
         $user = $facebook->require_login();
         if ($user) {
             MyAuth::setLoginAuthenticate($user);
         }
         $u = $user;
     }
     if (isset($realUser)) {
         $realUser = $u;
     }
     //Return the mock_user if the real user is an administrator and mockuser is set
     $mu = GetAdminDebug('mock_user');
     if ($mu != 'NONE' && in_array(intval($u), $adminUserIDs)) {
         return $mu;
     } else {
         return $u;
     }
 }
开发者ID:soychicka,项目名称:tg,代码行数:26,代码来源:FbAuth.php

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

示例4: get_fb

function get_fb()
{
    $appapikey = '60237d0a13480c24eb8f3eccf42d193e';
    $appsecret = 'e0504baa721280e66ed5c2f0148d8de2';
    $facebook = new Facebook($appapikey, $appsecret);
    $facebook->require_login();
    return $facebook;
}
开发者ID:quad,项目名称:isinrelationship,代码行数:8,代码来源:iir.php

示例5: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->rounds = Doctrine::getTable('Competition')->createQuery()->execute();
     $appapikey = sfConfig::get("app_facebook_api_key");
     $appsecret = sfConfig::get("app_facebook_api_secret");
     $facebook = new Facebook($appapikey, $appsecret);
     $facebook->require_frame();
     $user_id = $facebook->require_login();
     //$user_id = "1076694583";
     $this->getUser()->setAttribute('user_id', $user_id);
     $this->user = Doctrine::getTable('User')->getFBUser($user_id);
 }
开发者ID:sandaru1,项目名称:codejam,代码行数:17,代码来源:actions.class.php

示例6: __construct

 public function __construct()
 {
     $facebook = new Facebook(OpfApplicationConfig::SITE_API_KEY, OpfApplicationConfig::SITE_API_SECRET);
     $this->facebook = $facebook;
     $facebook->require_frame();
     $this->userId = $facebook->require_login();
     try {
         $this->addUrl = $facebook->get_add_url();
         $this->isAppAdded = $facebook->api_client->users_isAppAdded();
     } catch (Exception $e) {
         $facebook->set_user(null, null);
         $facebook->redirect(OpfApplicationConfig::APP_CALLBACK_URL);
     }
 }
开发者ID:TheProjecter,项目名称:openface,代码行数:14,代码来源:OpfSiteWrapper.php

示例7: authenticate

 /**
  * Log-in using Facebook platform
  *
  * @param array &$state  Information about the current authentication.
  */
 public function authenticate(&$state)
 {
     assert('is_array($state)');
     /* We are going to need the authId in order to retrieve this authentication source later. */
     $state[self::AUTHID] = $this->authId;
     $stateID = SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT);
     SimpleSAML_Logger::debug('facebook auth state id = ' . $stateID);
     $facebook = new Facebook($this->api_key, $this->secret);
     $u = $facebook->require_login($stateID);
     # http://developers.facebook.com/documentation.php?v=1.0&method=users.getInfo
     /* Causes an notice / warning...
     		if ($facebook->api_client->error_code) {
     			throw new Exception('Unable to load profile from facebook');
     		}
     		*/
     $info = $facebook->api_client->users_getInfo($u, array('first_name', 'last_name'));
     $fullname = $info[0]['first_name'] . ' ' . $info[0]['last_name'];
     $attributes = array('sn' => array($info[0]['last_name']), 'givenName' => array($info[0]['first_name']), 'cn' => array($info[0]['first_name'] . ' ' . $info[0]['last_name']), 'uid' => array($u), 'eduPersonPrincipalName' => array('facebook:' . $u));
     $state['Attributes'] = $attributes;
 }
开发者ID:hukumonline,项目名称:yii,代码行数:25,代码来源:Facebook.php

示例8: login

 function login()
 {
     App::import('vendor', 'Facebook', array('file' => 'facebook/facebook.php'));
     $appapikey = 'f056b8b1d196e8392199e8ba3acfadad';
     $appsecret = '0d1b22691586060b3647745ad41e5cd0';
     $facebook = new Facebook($appapikey, $appsecret);
     $user_id = $facebook->require_login();
     $appcallbackurl = '/facebook/bye';
     //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);
     		}*/
     return $facebook;
 }
开发者ID:dilzfiesta,项目名称:Freesmsapi,代码行数:24,代码来源:facebooks_controller.php

示例9: htmlentities

<?php 
echo htmlentities(file_get_contents('faith_style.css', true));
?>
</style>
</head>
<table cellspacing="0" cellpadding="0" width="750px">
<tr>
	<td>
	<?php 
require_once 'func.php';
require_once 'vars.php';
require_once 'facebook.php';
try {
    mysqlSetup($db);
    $facebook = new Facebook($appapikey, $appsecret);
    $user_id = $facebook->require_login();
    $results = mysql_query("SELECT transform_add.transform_add_id,\n\t\t\t\t\t\t\t\t   transform_add.add_uid_a,\n\t\t\t\t\t\t\t\t   transform_add.add_time,\n\t\t\t\t\t\t\t\t   transform_add.social_path,\n\t\t\t\t\t\t\t\t   transform_add.status\n\t\t\t\t\t\t\t\t   from transform_add\n\t\t\t\t\t\t\t\t   where transform_add.add_uid_b = {$user_id} AND\n\t\t\t\t\t\t\t\t   \t     transform_add.status = 0\n\t\t\t\t\t\t\t\t   order by transform_add.add_time DESC", $db);
    $div_counter = 0;
    while ($row = mysql_fetch_array($results)) {
        $div_counter++;
    }
    display_header_links($div_counter, $user_id);
} catch (Exception $e) {
    echo 'Caught database exception: ', $e->getMessage(), "\n";
}
?>
	</td>
</tr>
<tr>
	<td height="10px"></td>
</tr>
开发者ID:naken,项目名称:faith,代码行数:31,代码来源:service_privacy_shield.php

示例10: Facebook

<?php

/**
 * @copyright   Copyright (c) 2009 Oxidian d.o.o (http://www.oxidian.hr)
 * @license     http://www.opensource.org/licenses/GPL-2.0 GPL 2.0
 * @author      Goran Samboliæ 
 */
//http://www.facebook.com/apps/application.php?id=182006978670
require_once 'facebook-platform/facebook-platform/php/facebook.php';
require_once "../../fac/help.php";
return;
session_start();
$facebook = new Facebook("", "");
$fb_user = $facebook->require_login();
$user_details = $facebook->api_client->users_getInfo($fb_user, 'last_name, first_name, pic');
$_SESSION['faceInfo'] = $user_details[0]['uid'];
// store session data
$id = $user_details[0]['uid'];
$name = $user_details[0]['first_name'];
$lastname = $user_details[0]['last_name'];
$query = "call checkForUserExist(" . $id . ")";
$result = mysqli_query($conn, $query);
$res = mysqli_fetch_row($result);
if ($res[0] == 0) {
    mysqli_next_result($conn);
    $hash = md5($id . $name . $lastname);
    mysqli_next_result($conn);
    $query = "call  insertUserFace({$id},'{$name}', '{$lastname}','" . $user_details[0]['pic'] . "')";
    $result = mysqli_query($conn, $query);
}
?>
开发者ID:anhvn,项目名称:bet-script,代码行数:31,代码来源:index.php

示例11: Facebook

<?php

//
// Application: TripTracker
// File: 'index.php'
//
// Benn Eichhorn
// 15 Jan 2008
//
require_once 'facebook.php';
require_once 'config.php';
require_once 'lib.php';
$facebook = new Facebook($appApiKey, $appSecret);
$user_fb = $facebook->require_login();
if (isset($_POST['user_tt'])) {
    put_new_user($user_fb, $_POST['user_tt']);
}
?>
<fb:if-user-has-added-app>

	<div style="padding: 10px;">
	<h2>
	Hi <fb:name firstnameonly="true" uid="<?php 
echo $user_fb;
?>
" useyou="false"/>, welcome back to TripTracker.
	</h2>
	<?php 
$user_tt = get_tt_user($user_fb);
// if users has linked in their tt username
if ($user_tt !== FALSE) {
开发者ID:BGCX067,项目名称:facebook-app-triptracker-svn-to-git,代码行数:31,代码来源:index.php

示例12: Facebook

<?php

//
//  ${TM_NEW_FILE_BASENAME}
//
//  Created by ${TM_USERNAME} on ${TM_DATE}.
//  Copyright (c) ${TM_YEAR} ${TM_ORGANIZATION_NAME}. All rights reserved.
//
include_once '../client/facebook.php';
$api_key = "{$TM_FB_API}";
$secret = "{$TM_FB_SECRET}";
$fb = new Facebook($api_key, $secret);
$fb->require_frame();
$user = $fb->require_login();
?>

开发者ID:BGCX067,项目名称:facebooktextmate-svn-to-git,代码行数:15,代码来源:page.php

示例13: catch

    //-----------------------------------------------------------
} catch (Exception $e) {
    echo 'Caught database exception: ', $e->getMessage(), "\n";
}
?>
	</td>
</tr>
<tr>
	<td height="10px"></td>
</tr>
<?php 
require_once 'vars.php';
require_once 'facebook.php';
try {
    $facebook = new Facebook($appapikey, $appsecret);
    $user_id = $facebook->require_login($required_permissions = 'publish_stream,email,create_event,read_stream,rsvp_event,offline_access');
    if (isset($_GET['ffile']) && isset($_GET['fpro'])) {
        echo '<tr><td>';
        $fpro = $_GET['fpro'];
        $post_params = array();
        foreach ($_POST as $key => &$val) {
            if ($key != 'fb_sig_app_id') {
                $post_params[] = $key . '=' . urlencode($val);
            }
        }
        $faith_url_id = '0';
        $logging_setting = '0';
        try {
            $results = mysql_query("SELECT logging_setting\n\t\t\t\t\t\t\t\t   from setting_logging\n\t\t\t\t\t\t\t\t   where uid = {$user_id}", $db);
            while ($row = mysql_fetch_array($results)) {
                $logging_setting = $row['logging_setting'];
开发者ID:naken,项目名称:faith,代码行数:31,代码来源:index.php

示例14: dirname

	<body>
	<img style="position:absolute;top:0px;left:90px;" src="/images/theprojectlogotext.jpg" alt="The Project" />
<?php 
if (!$LOGIN_DATA['user_id']) {
    $_SESSION['return_to'] = 'http://theproject.singpolyma.net/facebook/';
    require_once dirname(__FILE__) . '/../login/form.php';
    echo '</body></html>';
    exit;
}
//end if user_id
require_once 'facebook.php';
$appapikey = '5502d60d6c4172a6f84ff7269aa8da80';
$appsecret = 'a603ff4995447f220eb65785b7f916fb';
$facebook = new Facebook($appapikey, $appsecret);
$fbid = $facebook->require_login();
require_once dirname(__FILE__) . '/../include/connectDB.php';
mysql_query("UPDATE users SET facebook_id={$fbid} WHERE user_id=" . $LOGIN_DATA['user_id'], $db) or die(mysql_error());
//import friends
$friends = $facebook->api_client->friends_get();
foreach ($friends as $friend) {
    $local = mysql_query("SELECT user_id FROM users WHERE facebook_id={$friend} LIMIT 1", $db) or die(mysql_error());
    $local = mysql_fetch_assoc($local);
    if ($local) {
        $exists = mysql_query("SELECT user_id FROM friends WHERE user_id=" . $LOGIN_DATA['user_id'] . " AND friend_id=" . $local['user_id'], $db) or die(mysql_error());
        if (!mysql_fetch_assoc($exists)) {
            mysql_query("INSERT INTO friends (user_id,friend_id) VALUES (" . $LOGIN_DATA['user_id'] . "," . $local['user_id'] . ")", $db) or die(mysql_error());
        }
    }
    //end if local
}
开发者ID:honchoman,项目名称:singpolyma,代码行数:30,代码来源:index.php

示例15: Facebook

<?php

// the facebook client library
include_once '../php/facebook.php';

// some basic library functions
include_once 'lib.php';

// this defines some of your basic setup
include_once 'config.php';

$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$user = $facebook->require_login($required_permissions = 'publish_stream,email,read_stream,status_update');



if (isset($_POST['to'])) {
  $prints_id = (int)$_POST['to'];
  $prints = do_step($user, $prints_id);
} else {
  if (isset($_GET['to'])) {
    $prints_id = (int)$_GET['to'];
  } else {
    $prints_id = $user;
  }
  $prints = get_prints($prints_id);
}


extract($_REQUEST);
开发者ID:rheza,项目名称:Custom-Facebook-Status,代码行数:31,代码来源:index.php


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