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


PHP Facebook::getSession方法代码示例

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


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

示例1: __construct

	/**
	 * Constructor
	 *
	 * @param int $apikey	the api key for the facebook user
	 * @param int $secret	the facebook secret for the application
	 */
	protected function __construct()
	{
		// cache a reference to the registry object
		global $vbulletin;
		$this->registry = $vbulletin;

		// initialize fb api and grab fb userid to cache locally
		try
		{
			// init the facebook graph api
			$this->facebook = new Facebook_vUrl(array(
			  'appId'  => $this->registry->options['facebookappid'],
			  'secret' => $this->registry->options['facebooksecret'],
			  'cookie' => true
			));

			// check for valid session without pinging facebook
			if ($this->fb_session = $this->facebook->getSession())
			{
				$this->fb_userid = $this->fb_session['uid'];

				// make sure local copy of fb session is up to date
				$this->validateFBSession();
			}
		}
		catch (Exception $e)
		{
			$this->fb_userid = null;
		}
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:36,代码来源:class_facebook.php

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

示例3: fb

 function fb()
 {
     $this->load->config('facebook');
     include_once APPPATH . 'third_party/facebook.php';
     $facebook = new Facebook(array('appId' => $this->config->item('facebook_app_id'), 'secret' => $this->config->item('facebook_api_secret'), 'cookie' => true));
     $session = $facebook->getSession();
     if (isset($session['uid'])) {
         $me = $facebook->api('/me');
         // kalo login fb apakah ada user ini
         $rows = $this->db->get_where('meta', array('fb_id' => $session['uid']))->row();
         if ($rows) {
             $row = $this->ion_auth->get_user_by_email($me['email']);
             $this->ion_auth_model->update_last_login($row->id);
             $session_data = array('email' => $row->email, 'id' => $row->id, 'user_id' => $row->id, 'group_id' => $row->group_id, 'group' => $row->group);
             $this->session->set_userdata($session_data);
             redirect($this->url_if_login);
         } else {
             $this->session->set_flashdata('message', 'Can\'t Find Your FB accounts mapping to our database member');
             redirect('member/registration/');
         }
     } else {
         $this->session->set_flashdata('message', 'Please Login To Your Facebook First');
         redirect('member/login', 'refresh');
     }
 }
开发者ID:ramatraya,项目名称:Cecille,代码行数:25,代码来源:login.php

示例4: setUpFacebookInteractions

 protected function setUpFacebookInteractions($options)
 {
     // Create our Facebook Application instance
     $facebook = new Facebook(array('appId' => $options['facebook_app_id']->option_value, 'secret' => $options['facebook_api_secret']->option_value, 'cookie' => false));
     //check status of current FB user
     $session = $facebook->getSession();
     $fb_user = null;
     if ($session) {
         $fb_user_id = $facebook->getUser();
         $fb_user = $facebook->api('/me');
     }
     // login or logout url will be needed depending on current user state.
     if (isset($fb_user)) {
         $logoutUrl = $facebook->getLogoutUrl();
         $fbconnect_link = '<img src="https://graph.facebook.com/' . $fb_user_id . '/picture" style="float:left;">' . $fb_user['name'] . '<br /><a href="' . $logoutUrl . '">
         <img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif"></a>';
     } else {
         $redirect_uri = urlencode('http://' . $_SERVER['SERVER_NAME'] . THINKUP_BASE_URL . 'account/?p=facebook');
         $params = array('req_perms' => 'offline_access,read_stream,user_likes,user_location,user_website,' . 'read_friendlists', 'redirect_uri' => $redirect_uri);
         $loginUrl = $facebook->getLoginUrl($params);
         $fbconnect_link = '<a href="' . $loginUrl . '"><img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif"></a>';
     }
     $this->addToView('fbconnect_link', $fbconnect_link);
     $status = self::processPageActions($fb_user);
     $this->addInfoMessage($status["info"]);
     $this->addErrorMessage($status["error"]);
     $this->addSuccessMessage($status["success"]);
     $logger = Logger::getInstance();
     $user_pages = array();
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     $owner_instances = $instance_dao->getByOwnerAndNetwork($this->owner, 'facebook');
     $ownerinstance_dao = DAOFactory::getDAO('OwnerInstanceDAO');
     foreach ($owner_instances as $instance) {
         $tokens = $ownerinstance_dao->getOAuthTokens($instance->id);
         $access_token = $tokens['oauth_access_token'];
         if ($instance->network == 'facebook') {
             //not a page
             $pages = FacebookGraphAPIAccessor::apiRequest('/' . $instance->network_user_id . '/likes', $access_token);
             if (@$pages->data) {
                 $user_pages[$instance->network_user_id] = $pages->data;
             }
         }
     }
     //print_r($user_pages);
     $this->addToView('user_pages', $user_pages);
     $owner_instance_pages = $instance_dao->getByOwnerAndNetwork($this->owner, 'facebook page');
     if (count($owner_instance_pages) > 0) {
         $this->addToView('owner_instance_pages', $owner_instance_pages);
     }
     $this->addToView('owner_instances', $owner_instances);
     if (isset($options['facebook_api_key'])) {
         $this->addToView('fb_api_key', $options['facebook_api_key']->option_value);
     }
 }
开发者ID:narpaldhillon,项目名称:ThinkUp,代码行数:54,代码来源:class.FacebookPluginConfigurationController.php

示例5: authenticate

 public function authenticate()
 {
     $facebook = new Facebook(array('appId' => $this->consumerKey, 'secret' => $this->consumerSecret, 'cookie' => true));
     $session = $facebook->getSession();
     if ($session) {
         $myFacebookInfo = $facebook->api('/me');
         if ($myFacebookInfo && isset($myFacebookInfo['id'])) {
             $identity = new stdClass();
             $identity->user_type = "facebook";
             //Check user exists in database.
             $facebookTable = VC_Db_TableAdapter_Locator::get("FacebookUser");
             $userTable = VC_Db_TableAdapter_Locator::get("User");
             $userInfoInDb = $facebookTable->findFacebookUserByFacebookId($myFacebookInfo['id']);
             if (!$userInfoInDb) {
                 //If not exist in db
                 //Insert to DB
                 $insertUserData = array();
                 $insertUserData['display_name'] = $myFacebookInfo['name'];
                 $insertUserData['type'] = "facebook";
                 $newUserId = $userTable->insertUser($insertUserData);
                 if ($newUserId) {
                     //Insert user to Facebook Table
                     $insertUserFBData = array();
                     $insertUserFBData['id'] = $newUserId;
                     $insertUserFBData['facebook_id'] = $myFacebookInfo['id'];
                     //$insertUserFBData['display_name'] = $myFacebookInfo['name'];
                     $insertUserFBData['email'] = $myFacebookInfo['email'];
                     $newFacebookUserId = $facebookTable->insertUser($insertUserFBData);
                     $biUserTable = new VC_Db_TableAdapter_BI_BiUser();
                     $biUserTable->insertBiUser($newUserId);
                     if (!$newFacebookUserId) {
                         $log = VC_Log::getLog();
                         $log->logMessage("Could not insert facebook user to USER table.", Zend_Log::ERR);
                     }
                     $identity->user_name = $myFacebookInfo['name'];
                     $identity->email = $myFacebookInfo['email'];
                     $identity->user_id = $newUserId;
                 } else {
                     $log = VC_Log::getLog();
                     $log->logMessage("Could not insert facebook user to USER table.", Zend_Log::ERR);
                     throw new VC_Exception("Could not insert Facebook user to database");
                 }
             } else {
                 //TODO: Update information to DB again
                 $identity->user_name = $myFacebookInfo['name'];
                 $identity->email = $myFacebookInfo['email'];
                 $identity->user_id = $userInfoInDb['id'];
             }
             return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity, array());
         }
     }
     return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, $this->consumerKey);
 }
开发者ID:BGCX261,项目名称:zillatek-project-svn-to-git,代码行数:53,代码来源:FacebookAdapter.php

示例6: getCredentials

 /**
  * 
  * Verify we have a facebook session and load the credentials
  * 
  * @return array List of authentication credentials
  * 
  */
 public function getCredentials()
 {
     // We have a possible session lets get our user data
     if ($this->_facebook->getSession()) {
         try {
             $fb_results = $this->_facebook->api('/me');
             return array('id' => $fb_results[$this->_config['fb_id']], 'handle' => $fb_results[$this->_config['fb_handle']], 'email' => $fb_results[$this->_config['fb_email']], 'moniker' => $fb_results[$this->_config['fb_moniker']], 'verified' => true);
         } catch (FacebookApiException $e) {
             // Session is invalid, login failed
         }
     }
     return false;
 }
开发者ID:kalkin,项目名称:solarphp,代码行数:20,代码来源:Facebook.php

示例7: login

 function login()
 {
     if ($this->uri->segment(3) == 'twitter') {
         $twitteroauth = new TwitterOAuth(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET);
         // Requesting authentication tokens, the parameter is the URL we will be redirected to
         $request_token = $twitteroauth->getRequestToken(site_url() . '/home/twitter');
         // Saving them into the session
         $this->session->set_userdata('oauth_token', $request_token['oauth_token']);
         $this->session->set_userdata('oauth_token_secret', $request_token['oauth_token_secret']);
         // If everything goes well..
         if ($twitteroauth->http_code == 200) {
             // Let's generate the URL and redirect
             $url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
             redirect($url, 'refresh');
         }
     } else {
         if ($this->uri->segment(3) == 'facebook') {
             $facebook = new Facebook(array('appId' => APP_ID, 'secret' => APP_SECRET, 'cookie' => true));
             $session = $facebook->getSession();
             if (!empty($session)) {
                 //Active session, let's try getting the user id (getUser()) and user info (api->('/me'))
                 try {
                     $uid = $facebook->getUser();
                     $user = $facebook->api('/me');
                 } catch (Exception $e) {
                 }
                 if (!empty($user)) {
                     //User info ok? Let's print it (Here we will be adding the login and registering routines)
                     //print_r($user);
                     $username = $user['name'];
                     $userdata = $this->usermodel->get_user($uid, 'facebook', $username);
                     if (!empty($userdata)) {
                         $this->session->set_userdata('id', $userdata['id']);
                         $this->session->set_userdata('oauth_id', $uid);
                         $this->session->set_userdata('username', $userdata['username']);
                         $this->session->set_userdata('oauth_provider', $userdata['oauth_provider']);
                         redirect(site_url(), 'refresh');
                     }
                 }
             } else {
                 # There's no active session, let's generate one
                 $login_url = $facebook->getLoginUrl();
                 redirect($login_url, 'refresh');
             }
         } else {
             //redirect 404?
         }
     }
 }
开发者ID:roppa,项目名称:glossarizr,代码行数:49,代码来源:home.php

示例8: Facebook

 public static function Facebook($user)
 {
     $fb = new Facebook(array('appId' => self::$config['appId'], 'secret' => self::$config['secret'], 'cookie' => true));
     $api = NULL;
     $user = NULL;
     $session = $fb->getSession();
     if ($session) {
         try {
             $user = $fb->getUser();
             $api = $fb->api($user);
         } catch (FacebookApiException $e) {
             parent::ErrorException('Facebook', $e, $user);
         }
     }
     return array('fb' => $fb, 'api' => $api, 'session' => $session);
 }
开发者ID:dvgamer,项目名称:It-My.Selfip,代码行数:16,代码来源:engine.php

示例9: beforeFilter

 function beforeFilter()
 {
     $this->RequestHandler->setContent('json', 'text/x-json');
     $facebook = new Facebook(array('appId' => '175485662472361', 'secret' => '4b66d239e574be89813bba4457b97a36', 'cookie' => true));
     $session = $facebook->getSession();
     if (empty($session)) {
         //  $this->redirect(array('controller'=>'users','action'=>'login'));
     }
     if (!empty($user_record)) {
         $user_record_1 = array();
         $user_record_1['Auth']['username'] = $user_record['User']['username'];
         $user_record_1['Auth']['password'] = $user_record['User']['password'];
         $this->Auth->authenticate_from_twitter($user_record_1['Auth']);
         $this->redirect('/');
     }
     //		endif;
 }
开发者ID:rogerwu99,项目名称:Smorgi,代码行数:17,代码来源:app_controller.php

示例10: getUid

 public static function getUid()
 {
     $culture = sfContext::getInstance()->getUser()->getCulture();
     $facebook_uid = false;
     $facebook = new Facebook(array('appId' => sfConfig::get("app_facebook_api_id_{$culture}"), 'secret' => sfConfig::get("app_facebook_api_secret_{$culture}"), 'cookie' => true));
     $session = $facebook->getSession();
     $me = null;
     if ($session) {
         try {
             $uid = $facebook->getUser();
             //$me = $facebook->api('/me');
             $facebook_uid = $uid;
         } catch (FacebookApiException $e) {
             error_log($e);
         }
     }
     return $facebook_uid;
 }
开发者ID:voota,项目名称:voota,代码行数:18,代码来源:VoFacebook.class.php

示例11: connect

 /**
  * connect
  */
 public function connect()
 {
     $facebook = new Facebook(array('appId' => $this->appId, 'secret' => $this->secret, 'cookie' => true));
     $session = $facebook->getSession();
     if (!empty($session)) {
         try {
             $uid = $facebook->getUser();
             $user = $facebook->api('/me');
             if (!empty($user['email'])) {
                 return $user;
             }
             return false;
         } catch (Exception $e) {
         }
     } else {
         # There's no active session, let's generate one
         $login_url = $facebook->getLoginUrl();
         header("Location: " . $login_url);
     }
 }
开发者ID:visualweber,项目名称:appzf1,代码行数:23,代码来源:Facebook.php

示例12: getSession

 public function getSession($redirect_uri = null)
 {
     $session = parent::getSession();
     if ($session) {
         return $session;
     }
     // oAuth 콜백 처리
     if (!isset($_REQUEST['code'])) {
         return null;
     }
     // state 검사
     if ($_SESSION['state'] != $_REQUEST['state']) {
         return null;
     }
     // 액세스 토큰 요청
     $response = $this->makeRequest($this->getUrl('graph', 'oauth/access_token'), array('client_id' => $this->getAppId(), 'client_secret' => $this->getApiSecret(), 'code' => $_REQUEST['code'], 'redirect_uri' => $redirect_uri));
     parse_str($response, $params);
     $this->setSession($params, true);
     return $params;
 }
开发者ID:leehankyeol,项目名称:module-server,代码行数:20,代码来源:facebook_socialxe.php

示例13: authenticate

 /**
  * Authenticates the user passed by the constructor, however in this case we
  * user the WRAP server variable "WRAP_USERID" to get this appropriate username.
  *
  * @return new Zend_Auth_Result object
  */
 public function authenticate()
 {
     if (AUTH_FB_APPID == '' || AUTH_FB_SECRET == '') {
         throw new Exception('Yahoo authentication options must be set in the application configuration.');
     }
     // Create our Application instance (replace this with your appId and secret).
     $facebook = new Facebook(array('appId' => AUTH_FB_APPID, 'secret' => AUTH_FB_SECRET, 'cookie' => true));
     $session = $facebook->getSession();
     $username = null;
     // Session based API call.
     if ($session) {
         try {
             $uid = $facebook->getUser();
             $me = $facebook->api('/me');
         } catch (FacebookApiException $e) {
             return new Zend_Auth_Result(false, new stdClass(), array($e->getMessage()));
         }
     }
     // login
     if (!$me) {
         header('location:' . $facebook->getLoginUrl());
         die;
     }
     $class = new stdClass();
     $class->username = $me['id'];
     $class->firstName = $me['first_name'];
     $class->lastName = $me['last_name'];
     $class->realm = 'facebook';
     return new Zend_Auth_Result(true, $class, array());
 }
开发者ID:ncsuwebdev,项目名称:otframework,代码行数:36,代码来源:Facebook.php

示例14: testSignedTokenInQuery

 public function testSignedTokenInQuery()
 {
     $facebook = new Facebook(array('appId' => self::APP_ID, 'secret' => self::SECRET));
     $_REQUEST['signed_request'] = self::$VALID_SIGNED_REQUEST;
     $this->assertNotNull($facebook->getSession());
     unset($_REQUEST['signed_request']);
 }
开发者ID:nightraiser,项目名称:rdine,代码行数:7,代码来源:tests.php

示例15: Facebook

<?php

require_once '../config.php';
$fbc = new Facebook(array('appId' => FB::$app_id, 'secret' => FB::$secret, 'cookie' => true));
$session = $fbc->getSession();
$writer = new Zend_Log_Writer_Stream(LOG_ROOT . 'user_pop.log');
Logger::registerLogger('user_pop', $writer, null, true);
Logger::debug(print_r($_POST, true));
Logger::debug(print_r($_GET, true));
Logger::debug(print_r($session, true));
开发者ID:uning,项目名称:mall-back,代码行数:10,代码来源:save_email.php


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