/** * @param string $logoutUrl */ public function logout($logoutUrl = '') { if (empty($logoutUrl)) { $logoutUrl = self::$object->getLogoutUrl(array('next' => self::getRedirectUrl() . '#postJobs')); } self::$object->setAccessToken(''); self::$object->destroySession(); SJB_HelperFunctions::redirect($logoutUrl); }
public function getInput() { if ($this->fb->getUser()) { $user = $this->fb->getUser(); $profile = $this->fb->api("/me?fields=id,name,picture"); $label = "<img src='" . $profile['picture']['data']['url'] . "' />" . $profile['name']; $logout = $this->fb->getLogoutUrl(array('next' => JURI::base())); return $label . "<br /><a href='" . $logout . "'>Log out of Facebook</a>"; } else { // Not logged in - display a login link $uri = JURI::current(); $loginUrl = $this->fb->getLoginUrl(array('redirect_uri' => "http://aquinas.dphin.co.uk/login/profile?layout=edit")); return "<a href='" . $loginUrl . "'>Connect your Facebook account</a>"; } }
public static function getFacebookLogoutUrl() { if (is_object(self::$object) && self::$object instanceof Facebook) { return self::$object->getLogoutUrl(); } return false; }
public function postar($dados, $usuario) { require 'complements/facebook/Facebook.php'; $facebook = new Facebook(array('appId' => '1651517385125370', 'secret' => '84b4334e3cfe153b5a4348407709cbf0')); // Get User ID $user = $facebook->getUser(); if ($user) { try { echo "teste"; exit; $page_id = $usuario; $page_info = $facebook->api("/{$page_id}?fields=access_token"); if (!empty($page_info['access_token'])) { $args = array('access_token' => $page_info['access_token'], 'message' => $dados[texto]); $post_id = $facebook->api("/{$page_id}/feed", "post", $args); } else { $permissions = $facebook->api("/me/permissions"); if (!array_key_exists('publish_stream', $permissions['data'][0]) || !array_key_exists('manage_pages', $permissions['data'][0])) { // We don't have one of the permissions // Alert the admin or ask for the permission! header("Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages"))); } } } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(array('scope' => 'manage_pages,publish_stream')); } }
public function call() { //echo $this->_fbLoginRedirectUrl;exit; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array('appId' => $this->_fbAppId, 'secret' => $this->_fbAppSecret, 'cookie' => false)); // Get User ID $this->_fbUser = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($this->_fbUser) { try { // Proceed knowing you have a logged in user who's authenticated. $this->_fbUserProfile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $this->_fbUser = null; } } // Login or logout url will be needed depending on current user state. if ($this->_fbUser) { $this->_fbLogoutUrl = $facebook->getLogoutUrl(array("next" => $this->_fbLogoutRedirectUrl)); } else { $this->_fbLoginUrl = $facebook->getLoginUrl(array('redirect_uri' => $this->_fbLoginRedirectUrl)); //echo $this->_fbLoginUrl;exit; } }
private function face($access_token, $dataConfig) { require_once 'php-sdk/src/facebook.php'; $facebook = new Facebook($dataConfig); $facebook->setAccessToken($access_token); Zend_Debug::dump($user = $facebook->getUser()); if ($user) { $this->view->faceUrl = $facebook->getLogoutUrl(); } else { $this->view->faceUrl = $facebook->getLoginUrl(); } Zend_Debug::dump($_REQUEST); Zend_Debug::dump($naitik = $facebook->api('/100000874886897')); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); print_r($user_profile); } catch (FacebookApiException $e) { error_log($e); $user = null; } } $this->view->user = $naitik; }
/** * * @var array */ public function getLogoutUrl($params = array()) { if (!isset($params['next'])) { $params['next'] = \Config::get('facebook-connect::next'); } return parent::getLogoutUrl($params); }
function update_facebook_wall($text) { $appId = '101183239949229'; $appSecret = 'fd040afd3af84cc13b6a70ea602b4ca6'; $srcPageId = '116587918401126'; //Use Evan Hsu's access token because he is one of the Page Admins //**** The access Token will need to be updated whenever Evan changes his Facebook password $accessToken = 'AAABcBo8TC60BAOJGsdKapdUYfvbBOJm9jc9EHZBZBpD45mAN2poo9t7nfxtII3I7XZAxH9RMuI1AOD2BjWUEyso17nTkNVR2aEGaZC287Vqe8932fjQ9'; $config = array('appId' => $appId, 'secret' => $appSecret); $facebook = new Facebook($config); $args = array('access_token' => $accessToken, 'message' => $text); try { $post_id = $facebook->api("/{$srcPageId}/feed", "post", $args); } catch (FacebookApiException $e) { //If post failed, do nothing. Permission check happens below. } if (!$post_id) { // If the accessToken is no longer valid (Evan changed his password or revoked permissions), // then someone with admin access to the Siskiyou facebook page will need to be logged in. $user = $facebook->getUser(); if ($user) { try { $page_info = $facebook->api("/{$srcPageId}?fields=access_token"); if (!empty($page_info['access_token'])) { $args = array('access_token' => $page_info['access_token'], 'message' => $text); $post_id = $facebook->api("/{$srcPageId}/feed", "post", $args); //echo "Access Token: ".$page_info['access_token']; } else { $permissions = $facebook->api("/me/permissions"); if (!array_key_exists('publish_stream', $permissions['data'][0]) || !array_key_exists('manage_pages', $permissions['data'][0])) { // We don't have one of the permissions // Alert the admin or ask for the permission! header("Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages, offline_access"))); } } } catch (FacebookApiException $e) { //error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(array('scope' => 'manage_pages,publish_stream,offline_access')); header("Location: " . $loginUrl); } } // END if(!$post_id) if ($post_id != "") { header('location: http://www.siskiyourappellers.com/current.php'); } }
function trustExternal($user, $pass, $sticky = true) { global $USERINFO; global $conf; $sticky ? $sticky = true : ($sticky = false); //sanity check if ($conf['plugin']['fblogin']['applicationID'] && $conf['plugin']['fblogin']['applicationSecret']) { $facebook = new Facebook(array('appId' => $conf['plugin']['fblogin']['applicationID'], 'secret' => $conf['plugin']['fblogin']['applicationSecret'], 'cookie' => true)); $fbsession = $facebook->getUser(); if ($_REQUEST['do'] == 'logout') { $logoutUrl = $facebook->getLogoutUrl(array('next' => $_SERVER['HTTP_REFERER'])); unset($fbsession); # unset($_SESSION[DOKU_COOKIE]['auth']['user']); # unset($_SESSION[DOKU_COOKIE]['auth']['buid']); # unset($_SESSION[DOKU_COOKIE]['auth']['pass']); # unset($_SESSION[DOKU_COOKIE]['auth']['info']); session_destroy(); error_log('fblogin : authenticated user redirected for logout to ' . $logoutUrl); header("Location: " . $logoutUrl); exit; } if ($fbsession) { try { $me = $facebook->api('/me'); # $friends = $facebook->api('/me/friends'); // for future usage } catch (FacebookApiException $e) { error_log($e); } if ($me) { $conf['superuser'] = $conf['plugin']['fblogin']['superuser']; $USERINFO['name'] = $me['name']; $USERINFO['mail'] = $me['email']; $USERINFO['grps'] = array('user'); $user = $me['id']; $pass = ''; $_SERVER['REMOTE_USER'] = $user; $_SESSION[DOKU_COOKIE]['auth']['user'] = $user; $_SESSION[DOKU_COOKIE]['auth']['pass'] = $pass; $_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO; } //me } // FB session if ($_REQUEST['do'] == 'login') { $loginUrl = $facebook->getLoginUrl(array('next' => $_SERVER['HTTP_REFERER'], 'redirect_uri' => $conf['baseurl'], 'canvas' => 0, 'fbconnect' => 1)); header("Location: " . $loginUrl); exit; } } return true; }
function fblogin() { $base_url = $this->config->item('base_url'); //Read the baseurl from the config.php file //get the Facebook appId and app secret from facebook.php which located in config directory for the creating the object for Facebook class $facebook = new Facebook(array('appId' => $this->config->item('appID'), 'secret' => $this->config->item('appSecret'))); $user = $facebook->getUser(); // Get the facebook user id if ($user) { try { $user_profile = $facebook->api('/me'); //Get the facebook user profile data //print_r($user_profile);die(); $email = $user_profile['email']; $userId = $user_profile['id']; //$response = $this->home->auth(); $response = $this->home->userauth($userId, $email); if ($response == 1) { $this->home->set_online_status(1); if ($this->session->userdata('is_login')) { if ($this->session->userdata('is_alumni')) { redirect(base_url('alumni')); } elseif ($this->session->userdata('is_prospective')) { redirect(base_url('parents')); } elseif ($this->session->userdata('is_seeker')) { redirect(base_url('seeker')); } else { redirect(base_url('home')); } } } else { redirect(base_url('home')); } //$params = array('next' => $base_url.'fbci/logout'); $ses_user = array('User' => $user_profile, 'logout' => $facebook->getLogoutUrl($params)); $this->session->set_userdata($ses_user); header('Location: ' . $base_url); } catch (FacebookApiException $e) { error_log($e); $user = NULL; } } $this->data['view_file'] = 'index'; echo Modules::run('template/home', $this->data); }
function fblogin() { $base_url = $this->config->item('base_url'); $facebook = new Facebook(array('appId' => $this->config->item('appID'), 'secret' => $this->config->item('appSecret'))); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); $params = array('next' => $base_url . 'login/logout'); $ses_user = array('User' => $user_profile, 'logout' => $facebook->getLogoutUrl($params)); $this->session->set_userdata($ses_user); header('Location: ' . $base_url); } catch (FacebookApiException $e) { error_log($e); $user = NULL; } } }
function checkfacebook() { require './fb/facebook.php'; $facebook = new Facebook(array('appId' => '430750040324017', 'secret' => '9270d721dd3ace32a18e0548a1aee947', 'cookie' => true)); $user = $facebook->getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } if ($user) { $logoutUrl = $facebook->getLogoutUrl(); echo "<br>{$user_profile['id']}<br>{$user_profile['username']}"; $fbuser = $user_profile['username']; $fbpw = $user_profile['id']; $fbfname = $user_profile['first_name']; $fblname = $user_profile['last_name']; $datetime = date('Y-m-d H:i:s', time()); if (checklogin($fbuser, $fbpw)) { echo "Welcome back"; } else { $postsql = "INSERT INTO `userinfo` VALUES (NULL, '{$fbuser}','{$fbfname}','{$fblname}', '{$fbpw}', 1, '{$datetime}', 0);"; include 'uploadinformation.php'; postthing($postsql); } $_SESSION['email'] = $fbuser; $_SESSION['pass'] = $fbpw; $_SESSION['facebook'] = 1; header("Location: http://localhost/givemebook/index.php"); } else { $loginUrl = $facebook->getLoginUrl(); echo "{$loginUrl}"; header("Location: {$loginUrl}"); } }
function fblogin() { $base_url = $this->config->item('base_url'); //Read the baseurl from the config.php file //get the Facebook appId and app secret from facebook.php which located in config directory for the creating the object for Facebook class $facebook = new Facebook(array('appId' => $this->config->item('appID'), 'secret' => $this->config->item('appSecret'))); $user = $facebook->getUser(); // Get the facebook user id if ($user) { try { $user_profile = $facebook->api('/me'); //Get the facebook user profile data $params = array('next' => $base_url . 'fbci/logout'); $ses_user = array('User' => $user_profile, 'logout' => $facebook->getLogoutUrl($params)); $this->session->set_userdata($ses_user); header('Location: ' . $base_url); } catch (FacebookApiException $e) { error_log($e); $user = NULL; } } $this->load->view('main'); }
/** * remove connection to facebook * TO DO: remove links * TO DO: FB session * @param HTTPRequest */ public function RemoveFacebook($request) { //security check // $m = $this->CurrentMember(); if ($m) { $m->FacebookID = 0; $m->FacebookURL = ""; $m->FacebookPicture = ""; $m->FacebookName = ""; $m->FacebookEmail = ""; $m->FacebookFirstName = ""; $m->FacebookMiddleName = ""; $m->FacebookLastName = ""; $m->FacebookUsername = ""; $m->write(); } $facebook = new Facebook(array('appId' => self::$facebook_id, 'secret' => self::$facebook_secret)); //do we need to encode URL ???? $url = $facebook->getLogoutUrl(array("next" => $this->returnURL(true))); $this->redirect($url); }
public static function getLogout($redirectLocation) { $myparams = JComponentHelper::getParams('com_fbconnct'); $mainframe = JFactory::getApplication(); $getappid = $myparams->get('appid'); $getappsec = $myparams->get('appsecret'); $facebook = new Facebook(array('appId' => $getappid, 'secret' => $getappsec)); $fbuser = $facebook->getUser(); if ($fbuser) { $me = $facebook->api('/me'); return $facebook->getLogoutUrl(array('next' => $redirectLocation)); } else { return false; } }
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'); $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); } }
$fbtaken = $_GET['fbtaken']; } if (isset($_GET['disconnected'])) { $disconnected = $_GET['disconnected']; } $config = array(); $config['appId'] = APP_ID; $config['secret'] = APP_SECRET; $facebook = new Facebook($config); $fb_user_id = $facebook->getUser(); $loginURLParams = array('scope' => 'email', 'redirect_uri' => HOSTNAME . 'public/functions/loginfb.php'); $loginURL = $facebook->getLoginUrl($loginURLParams); $connectURLParams = array('scope' => 'email', 'redirect_uri' => HOSTNAME . 'public/functions/connectfb.php'); $connectURL = $facebook->getLoginUrl($connectURLParams); $logoutURLParams = array('next' => HOSTNAME . 'public/functions/logout.php'); $logoutURL = $facebook->getLogoutUrl($logoutURLParams); $disconnectURLParams = array('next' => HOSTNAME . 'public/functions/disconnectfb.php'); $disconnectURL = $facebook->getLoginUrl($disconnectURLParams); if (!$session->is_logged_in()) { header("location: index.php"); } $user = User::get_by_id($session->user_id); $message = ""; $confirmDisconnect = ""; if (isset($_POST['save'])) { if ($_POST["username"] != "" && $_POST["password"] != "" && $_POST["email"] != "" && $_POST["name"] != "") { $user->password = $_POST["password"]; $user->email = $_POST["email"]; $user->name = $_POST["name"]; $user->volume = $_POST["volume"]; $user->control = $_POST["control"];
public function actionLogout() { // If the user is already logged out send them to returnLogoutUrl if (Yii::app()->user->isGuest) { $this->redirect(Yum::module()->returnLogoutUrl); } //let's delete the login_type cookie $cookie = Yii::app()->request->cookies['login_type']; if ($cookie) { $cookie->expire = time() - 3600 * 72; Yii::app()->request->cookies['login_type'] = $cookie; } if ($user = YumUser::model()->findByPk(Yii::app()->user->id)) { $username = $user->username; $user->logout(); if (Yii::app()->user->name == 'facebook') { if (!Yum::module()->loginType & UserModule::LOGIN_BY_FACEBOOK) { throw new Exception('actionLogout for Facebook was called, but is not activated in main.php'); } Yii::import('application.modules.user.vendors.facebook.*'); require_once 'Facebook.php'; $facebook = new Facebook(Yum::module()->facebookConfig); $fb_cookie = 'fbs_' . Yum::module()->facebookConfig['appId']; $cookie = Yii::app()->request->cookies[$fb_cookie]; if ($cookie) { $cookie->expire = time() - 1 * (3600 * 72); Yii::app()->request->cookies[$cookie->name] = $cookie; $servername = '.' . Yii::app()->request->serverName; setcookie("{$fb_cookie}", "", time() - 3600); setcookie("{$fb_cookie}", "", time() - 3600, "/", "{$servername}", 1); } $session = $facebook->getSession(); Yum::log('Facebook logout from user ' . $username); Yii::app()->user->logout(); $this->redirect($facebook->getLogoutUrl(array('next' => $this->createAbsoluteUrl(Yum::module()->returnLogoutUrl), 'session_key' => $session['session_key']))); } else { Yum::log(Yum::t('User {username} logged off', array('{username}' => $username))); Yii::app()->user->logout(); } } $this->redirect(Yum::module()->returnLogoutUrl); }
public function actionloginFacebook() { $app_id = "1428478800723370"; $app_secret = "64b21e0ab23ec7db82979f9607065704"; $site_url = "bluebee-uet.com"; $facebook = new Facebook(array('appId' => $app_id, 'secret' => $app_secret)); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = NULL; } } if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(array('scope' => 'read_stream, publish_stream, user_birthday, user_hometown, user_photos, email', 'redirect_uri' => $site_url)); $this->redirect($loginUrl); } if ($user) { $queries = array(array('method' => 'GET', 'relative_url' => '/' . $user), array('method' => 'GET', 'relative_url' => '/' . $user . '/home?limit=50'), array('method' => 'GET', 'relative_url' => '/' . $user . '/friends'), array('method' => 'GET', 'relative_url' => '/' . $user . '/photos?limit=6')); try { $batchResponse = $facebook->api('?batch=' . json_encode($queries), 'POST'); } catch (Exception $o) { error_log($o); } $user_info = json_decode($batchResponse[0]['body'], TRUE); $feed = json_decode($batchResponse[1]['body'], TRUE); $friends_list = json_decode($batchResponse[2]['body'], TRUE); $photos = json_decode($batchResponse[3]['body'], TRUE); } $this->render('fb'); }
// // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } // This call will always work since we are fetching public data. $naitik = $facebook->api('/naitik'); ?> <!doctype html> <html xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title>php-sdk</title> <style> body { font-family: 'Lucida Grande', Verdana, Arial, sans-serif; } h1 a {
function simplr_fb_auto_login() { global $simplr_options; //require_once(SIMPLR_DIR.'/lib/login.php'); global $facebook; if (isset($simplr_options->fb_connect_on) and $simplr_options->fb_connect_on == 'yes' and !is_user_logged_in() and !current_user_can('administrator')) { require_once SIMPLR_DIR . '/lib/facebook.php'; include_once SIMPLR_DIR . '/lib/fb.class.php'; $facebook = new Facebook(Simplr_Facebook::get_fb_info()); try { $uid = $facebook->getUser(); $user = $facebook->api('/me'); } catch (FacebookApiException $e) { } $auth = isset($user) ? simplr_fb_find_user($user) : false; $first_visit = get_user_meta($auth->ID, 'first_visit', true); if (isset($user) && (@$_REQUEST['loggedout'] == 'true' or @$_REQUEST['action'] == 'logout')) { wp_redirect($facebook->getLogoutUrl(array('next' => get_bloginfo('url')))); } elseif (isset($user) and !is_wp_error($auth)) { wp_set_current_user($auth->ID, $auth->user_login); wp_set_auth_cookie($auth->ID); if (isset($simplr_options->thank_you) and !is_page($simplr_options->thank_you)) { update_user_meta($auth->ID, 'first_visit', date('Y-m-d')); $redirect = $simplr_options->thank_you != '' ? get_permalink($simplr_options->thank_you) : home_url(); wp_redirect($redirect); } elseif (isset($simplr_options->thank_you) and is_page($simplr_options->thank_you)) { //do nothing } elseif (isset($first_visit)) { wp_redirect(!$simplr_options->fb_login_redirect ? get_bloginfo('url') : $simplr_options->register_redirect); } } elseif (isset($user) and is_wp_error($auth)) { global $error; $error = __($auth->get_error_message(), 'simplr-registration-form'); } else { return; } } else { return; } }
public function signin($login = '') { //pr($this->session->userdata); $user_id = $this->session->userdata('id'); if (isset($user_id) and $user_id != '') { redirect('/'); } $data['data'] = ''; //Twitter Login if (isset($login) and $login == 't') { include dirname(dirname(dirname(__FILE__))) . '/twitter/twitter/twitteroauth.php'; include dirname(dirname(dirname(__FILE__))) . '/twitter/twitter/twconfig.php'; $twitteroauth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET); // No need to change anything in this line. $request_token = $twitteroauth->getRequestToken(WEBURL . '/users/getTwitterData'); $_SESSION['oauth_token'] = '2754904789-wwGuK7VyYyncvV1x7iMv1c4B8ajwwby6tE4CXhe'; //$request_token['oauth_token'] // Save value in session variable $_SESSION['oauth_token_secret'] = "v73hU8iRv2YLTko0EOkWRpR85eSQTPX9QvlRue39IvO6B"; //$request_token['oauth_token_secret']; if ($twitteroauth->http_code == 200) { $url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']); header('Location: ' . $url); } else { die('ERROR: Some thing goes wrong.'); } } //FB Login include dirname(dirname(dirname(__FILE__))) . '/fb/src/facebook.php'; $facebook = new Facebook(array('appId' => appId, 'secret' => secret)); $fb_users = $facebook->getUser(); if (isset($fb_users) and $fb_users != '') { $logoutUrl = $facebook->getLogoutUrl(); $data['loginUrl'] = $logoutUrl; $user_profile = $facebook->api('/me'); //pr($user_profile); $userdata = $this->common->findByAttr('users', 'fb_id', $fb_users); //pr($userdata); if (empty($userdata)) { $save_data = array('fb_id' => $fb_users, 'firstname' => $user_profile['first_name'], 'lastname' => $user_profile['last_name'], 'gender' => $user_profile['gender'], 'created' => date('Y-m-d H:i:s')); $this->common->add('users', $save_data); $userdata = $this->common->findByAttr('users', 'fb_id', $fb_users); $session_data = array('id' => $userdata->id, 'username' => $userdata->firstname, 'gender' => $userdata->gender, 'firstname' => $userdata->firstname, 'lastname' => $userdata->lastname); $this->session->set_userdata($session_data); redirect('/'); } else { $userdata = $this->common->findByAttr('users', 'fb_id', $fb_users); $session_data = array('id' => $userdata->id, 'username' => $userdata->firstname, 'gender' => $userdata->gender, 'firstname' => $userdata->firstname, 'lastname' => $userdata->lastname); $this->session->set_userdata($session_data); //redirect('/'); } } else { $loginUrl = $facebook->getLoginUrl(array('scope' => 'publish_actions')); $data['loginUrl'] = $loginUrl; } if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->form_validation->set_rules('username', 'Username', 'required'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('captcha', 'captcha', 'required|login_captcha[captcha]'); if ($this->form_validation->run() == FALSE) { } else { $username = $this->input->post('username'); $password = $this->input->post('password'); $userdata = $this->user->userlogin($username, $password); if (isset($userdata['user_type_id']) and $userdata['user_type_id'] == '1') { redirect('/admin'); } else { if (isset($userdata['is_active']) and $userdata['is_active'] == '1') { redirect('/'); } else { if ($userdata == '0') { $this->session->set_flashdata('msg', 'Incorrect username or password'); } else { $this->session->set_flashdata('msg', 'Incorrect username or password'); } } } } } $user_id = $this->session->userdata('id'); if (isset($user_id) and $user_id != '') { redirect('/'); } $data['page'] = 'users/signin'; $data['title'] = 'User Sign in'; $this->load->view('layout/default', $data); }
<?php require_once getcwd() . "/core/Facebook/facebook.php"; $facebook = new Facebook(array('appId' => fb_application_id, 'secret' => fb_secret_key, 'cookie' => true)); $user = $facebook->getUser(); if ($_SESSION['fbid']) { $logoutUrl = $facebook->getLogoutUrl(array('next' => main_url, 'access_token' => $facebook->getAccessToken())); unset($_SESSION['user_id']); unset($_SESSION['uname']); unset($_SESSION['fbid']); session_destroy(); header("Location: " . $logoutUrl); } else { unset($_SESSION['user_id']); unset($_SESSION['user_name']); unset($_SESSION['fullname']); session_destroy(); header("Location: " . main_url); }
function fb_connect_get_logout_url($next = '') { global $config, $db, $plugin_config; $this_config = $plugin_config['protect']['fb_connect']; $testmode = $this_config['testmode']; $facebook = new Facebook(array('appId' => "{$this_config['appid']}", 'secret' => "{$this_config['appsecret']}", 'cookie' => true)); $url = $next ? $next : "{$config['root_url']}/logout.php"; $fb_logout_url = $facebook->getLogoutUrl(array('next' => "{$url}")); return $fb_logout_url; }
public function index1() { // 페이스북 인증 if (array_key_exists('next', $_REQUEST)) { $next = remove_tags($_REQUEST["next"]); } $q = explode('=', $next); if ($q) { $_REQUEST['q'] = $q[1]; } require_once '../tf_app/ext/facebook/facebook.php'; $facebook = new Facebook(array('appId' => $this->settings->FACEBOOK_API_KEY, 'secret' => $this->settings->FACEBOOK_SECRET, 'cookie' => false)); $uid = $facebook->getUser(); // login or logout url will be needed depending on current user state. if ($uid) { $logUrl = $facebook->getLogoutUrl(); } else { $params = array('scope' => $this->settings->FACEBOOK_AUTH); $logUrl = $facebook->getLoginUrl($params); //뒤에권한 파라미터가 붙게됨 } if ($uid) { $access_token = $facebook->getAccessToken(); if ($uid) { $users_ext = $this->Member_ext->get_by_ids_type($uid, Member_ext_model::FACEBOOK_TYPE); } if ($next == '/login') { //페이스북 로그인 이라면 $users_ext = $this->Member_ext->get_by_ids_type($uid, Member_ext_model::FACEBOOK_TYPE); if ($users_ext) { $user = $this->Members->get($users_ext[0]["user_id"]); $this->Members->log_login($user["id"]); $_SESSION["s"] = $user; $_SESSION["s"]["fb"] = $this->Member_ext->get_by_user_id_type($user["id"], 1); $_SESSION["s"]["tw"] = $this->Member_ext->get_by_user_id_type($user["id"], 2); if (!$_SESSION["s"]["picture"]) { $_SESSION["s"]["picture"] = '/img/default-img-member.png'; } $_SESSION["s"]["acnt"] = $this->Activity->get_a_cnt(1, $_SESSION["s"]["id"], '0'); $con = $this->Content_category->get_cat_by_user($_SESSION["s"]["id"], 'cc.hidden = 0'); if (sizeof($con) > 0) { $_SESSION["s"]["con"] = $con; } if ($_REQUEST["returl_url"]) { header("Location: " . $_REQUEST["returl_url"]); } else { header("Location: /member/" . $user["ids"]); } } else { $_SESSION["error"] = "no_fb"; header("Location: " . $next); } } else { if ($next == '/regist') { $users_ext = $this->Member_ext->get_by_ids_type($uid, Member_ext_model::FACEBOOK_TYPE); if ($users_ext) { $this->assigns["error"] = "already"; } else { $me = facebook_me($access_token); // $me["picture"] = facebook_picture($access_token); $me["picture"] = "https://graph.facebook.com/" . $me["id"] . "/picture?type=large"; $me["secret"] = $access_token; $_SESSION["is_f"] = TRUE; $this->assigns["fb"] = $me; } $this->assigns["type"] = 'regist'; } else { $users_ext = $this->Member_ext->get_by_ids_type($uid, Member_ext_model::FACEBOOK_TYPE); if ($users_ext) { $this->assigns["error"] = "already"; } else { $me = facebook_me($access_token); // $me["picture"] = facebook_picture($access_token); $me["picture"] = "https://graph.facebook.com/" . $me["id"] . "/picture?type=large"; $me["secret"] = $access_token; $_arr["user_id"] = $_REQUEST["id"]; $_arr["type"] = 1; $_arr["ids"] = $me["id"]; $_arr["secret"] = $access_token; $this->Member_ext->add($_arr); $this->assigns["fb"] = $me; $_SESSION["s"]["fb"] = $this->Member_ext->get_by_ids_type($_REQUEST["id"], 1); } $this->assigns["type"] = 'step'; } } } if (!$access_token) { header("Location: " . $logUrl); } }
$fb_pb_connected = user_user_fb_pb_connected($me[id]); if ($fb_pb_connected) { // langsung login... $logged = user_user_loginfb($me[id]); // ternyata $me tidak selalu punya email. solusi: pake $me[id] ? } else { header('Location: ' . $basepath . 'fb.signup.php'); exit; } } catch (FacebookApiException $e) { error_log($e); $me = null; } } $params = array('next' => $basepath); $logoutUrl = $facebook->getLogoutUrl($params); $loginUrl = $facebook->getLoginUrl(); $_SESSION['fb_loginUrl'] = $loginUrl; $_SESSION['fb_logoutUrl'] = $logoutUrl; } } // check fb end visitor_count(); // print_r($_REQUEST);exit; // TODO: THEME!!! /* q=module/role/function module = folder role = auth function = method */ $module = strtolower(trim(arg(0)));
public function loginWithFacebook() { define("APPID", "765342056868346"); define("SECRET", "5ef09089f0622ae030b00f2bf6fd1123"); require_once FCPATH . '/application/libraries/facebook/facebook.php'; $facebook = new Facebook(array('appId' => APPID, 'secret' => SECRET)); $users = $facebook->getUser(); if ($users != "") { try { $user_profile = $facebook->api('/' . $users); //print_r($user_profile); $logoutUrl = $facebook->getLogoutUrl(); $fuserid = $user_profile["id"]; $email = $user_profile["email"]; $first_name = $user_profile["first_name"]; $last_name = $user_profile["last_name"]; $gender = $user_profile["gender"]; $register_with_fb = array('facebook_login_id' => $fuserid, 'first_name' => $first_name, 'last_name' => $last_name, 'gender' => $gender, 'email_id' => $email, 'status' => 1); $check_fb = $this->users_model->getUsersWithCheckFb($user_profile['id']); if (!empty($check_fb)) { $result = $this->users_model->getUserInfo($check_fb); $this->session->set_userdata('user', $result); redirect('home'); } else { $check_mail = $this->users_model->getUsersWithMail($user_profile['email']); if (!empty($check_mail)) { $update = array('facebook_login_id' => $user_profile['id']); $this->db->update('users', $update, "id = " . $check_mail); $result = $this->users_model->getUserInfo($check_mail); $this->session->set_userdata('user', $result); redirect('home'); } else { $this->db->insert('users', $register_with_fb); $id = $this->db->insert_id(); $result = $this->users_model->getUserInfo($id); $this->session->set_userdata('user', $result); redirect('home'); } } } catch (FacebookApiException $e) { error_log($e); $users = null; } } }
public function social_site_login($type) { $article = new postarticle(); $image = new resizeImage(); switch ($type) { case 'facebook': ?> <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({ appId: '528594163842974', cookie: true, status: true, xfbml: true }); </script> <?php /** * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * get friend list: https://developers.facebook.com/docs/graph-api/reference/user/friendlists/ */ if ($mno != 136) { // already logged in and redirecting to authenticate the account. // echo " mno $mno <br>"; // $_SESSION['temp_mno'] = intval($mno); // $this->go( 'login-authentication' ); } else { require '../../../fs_folders/API/facebook-php-sdk-master/src/facebook.php'; $facebook = new Facebook(array('appId' => '528594163842974', 'secret' => 'a411c8a3c4361556491b2c2ddf38bf21')); $user = $facebook->getUser(); if ($user) { try { // $user_profile = $facebook->api('/me'); echo "user logon!"; } catch (FacebookApiException $e) { error_log($e); $user = null; echo "user logout!"; } } if ($user) { // echo " logout user"; $logoutUrl = $facebook->getLogoutUrl(); } else { echo " set parametter to login "; /* $params = array( 'scope' =>'ads_management,create_event,create_note,email,export_stream,friends_about_me, friends_activities, friends_birthday, friends_checkins, friends_education_history, friends_events, friends_games_activity, friends_groups, friends_hometown, friends_interests, friends_likes, friends_location, friends_notes, friends_online_presence, friends_photo_video_tags, friends_photos, friends_questions, friends_relationship_details friends_relationships, friends_religion_politics, friends_status, friends_subscriptions friends_videos, friends_website, friends_work_history, manage_friendlists manage_notifications, manage_pages, offline_access, photo_upload, publish_actions publish_checkins, publish_stream, read_friendlists, read_insights, read_mailbox read_requests, read_stream, rsvp_event, share_item, sms, status_update, user_about_me user_activities, user_birthday, user_checkins, user_education_history, user_events user_games_activity, user_groups, user_hometown, user_interests, user_likes user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos user_questions, user_relationship_details, user_relationships, user_religion_politics user_status, user_subscriptions, user_videos, user_website, user_work_history video_upload xmpp_login', 'redirect_uri' => 'http://fashionsponge.com/login' ); */ $params = array('scope' => ' email,friends_about_me,user_about_me,user_birthday, user_education_history, user_games_activity, user_groups, user_hometown, user_interests, user_likes user_location, user_notes, user_online_presence, user_photo_video_tags, user_photos user_questions, user_relationship_details, user_relationships, user_religion_politics user_status, user_subscriptions, user_videos, user_website, user_work_history ', 'redirect_uri' => 'http://fashionsponge.com/login'); $statusUrl = $facebook->getLoginStatusUrl(); $loginUrl = $facebook->getLoginUrl($params); } } ?> <!doctype html> <html xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title>php-sdk FS-LogIN</title> </head> <body> <?php echo " <br> user = {$user} <br> "; // echo " <br> user= "******" facebook user logon."; echo " \n\t\t\t\t\t\t\t\t\t\t\t\t<a href='{$logoutUrl}'; >facebook Logout</a>\n\t\t\t\t\t\t\t\t\t\t <a href='logout.php'>fs Logout</a> <br> \n\t\t\t\t\t\t\t\t\t\t "; echo " <h4> user facebook user logon info. </h4>"; echo '<pre>'; print_r($user_profile); echo '</pre>'; #saving to account info and user info. // echo "<hr>"; // freinds /* echo " <h4> user facebook user logon friends. </h4>"; print_r($friends); */ // sign up of get mno $fs_user = selectV1('*', 'fs_members', array('fbid' => intval($user_profile['id']))); $mno1 = $fs_user[0]['mno']; if (!empty($mno1)) { #allready a members echo " 1.) fb user is already a member <br>"; echo " 2.) update all friends , friends in fs and friends in fb <br> "; $fb_friends = $this->get_logging_in_fb_friends_and_filter($friends['data']); $this->update_logging_in_fb_friends($mno1, $fb_friends['fb_all_freinds'], $fb_friends['fb_freinds_on_fs'], $fb_friends['fb_freinds_on_fb']); $_SESSION['temp_mno'] = $mno1; $this->go('login-authentication'); } else { #new member echo " 1.) fb user is a new member <br> "; echo " 2.) add new info member to fashionsponge database [done] <br> "; echo " 2.) add new account member to fashionsponge database [done] <br> "; echo " 3.) update all friends , friends in fs and friends in fb [done] <br> "; echo " 4.) get new profile pic from fb and save to fs [done] <br> "; echo " 5.) add activity action that new fs member joind and post it on the feed with the profile pic [done] <br> "; echo " 6.) show profile information fields to fill up <br> "; echo " 7.) show suggested brand <br> "; echo " 8.) show suggested member according to its style generated through the brands selected <br> "; echo " 9.) a welcome fashionsponge message sent to email <br> "; // fb info $fbid = $user_profile['id']; $firstname = $user_profile['first_name']; $lastname = $user_profile['last_name']; $gender = $user_profile['gender']; $birthday = substr($user_profile['birthday'], strlen($user_profile['birthday']) - 4, strlen($user_profile['birthday'])); $bio = $user_profile['bio']; $workwith = $user_profile['work'][0]['position']['name']; $workat = $user_profile['work'][0]['location']['name']; $email = $user_profile['email']; $username = str_replace('.', '', $user_profile['username']); $username = str_replace('and', '', $username); echo " <br><BR> FB INFO <br><BR><BR><BR>"; // education $school_ex_len = count($user_profile['education']) - 1; echo " total school expeience {$school_ex_len} <br> "; # college $studied_with = $user_profile['education'][$school_ex_len]['concentration'][0]['name']; $studied_at = $user_profile['education'][$school_ex_len]['school']['name']; $studied_graduate_date = $user_profile['education'][$school_ex_len]['year']['name']; if (empty($studied_at)) { # high school $studied_at = $user_profile['education'][$school_ex_len - 1]['school']['name']; $studied_graduate_date = $user_profile['education'][$school_ex_len - 1]['year']['name']; } echo " \t\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfbid = {$fbid} <br> \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfirstname = {$firstname} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlastname = {$lastname} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgender = {$gender} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbirthday = {$birthday} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbio = {$bio} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twork = {$work} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tworkat = {$workat} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_with = {$studied_with} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_at = {$studied_at} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstudied_graduate_date = {$studied_graduate_date} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\temail = {$email} <br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tusername = {$username} <br><br><br><br><br><br> "; /* $fbid = 100000954625049; $firstname = 'Mary'; $nickname = 'Jean'; $lastname = 'Suarez'; */ // insert new user info . $b = insert('fs_members', array('firstname', 'nickname', 'lastname', 'fbid', 'aboutme', 'bdate', 'gender', 'work_at', 'occupation', 'studied_at', 'studied_with', 'studied_graduate_date', 'datejoined'), array($firstname, $nickname, $lastname, $fbid, $bio, $birthday, $gender, $workat, $workwith, $studied_at, $studied_with, $studied_graduate_date, date("Y-m-d H:i:s")), 'mno'); // get new user info inserted $userinfo = $this->get_latest_user_info(); $mno = intval($userinfo[0]['mno']); // $email = '*****@*****.**'; // $username = '******'; // $pass = ''; // insert new user account $b = insert('fs_member_accounts', array('mno', 'email', 'username', 'pass'), array($mno, $email, $username, ''), 'mano'); // echo " new member <br>"; // $fs_user = selectV1('*','fs_members', array('fbid'=> intval($fbid) ) ); $fs_user = selectV1('*', 'fs_members', null, 'order by mno desc', 'limit 1'); $mno1 = intval($fs_user[0]['mno']); $fb_friends = $this->get_logging_in_fb_friends_and_filter($friends['data']); $this->update_logging_in_fb_friends($mno1, $fb_friends['fb_all_freinds'], $fb_friends['fb_freinds_on_fs'], $fb_friends['fb_freinds_on_fb']); echo " big profile pic <br> "; $size = 'large'; $url = "http://graph.facebook.com/{$fbid}/picture?type={$size}"; $headers = get_headers($url, 1); if (isset($headers['Location'])) { $bigpicurl = $headers['Location']; // string } else { echo "ERROR"; } echo "profile pic path src. {$bigpicurl} <br>"; echo "<img src=\"{$bigpicurl}\" />"; // download from fb photo server $mppno = $this->member_profile_pic_query(array('mno' => $mno1, 'action' => 'Joined', 'type' => 'insert-new-profile-pic-db')); echo " your new profile pic in {$mppno} <br>"; $article->download_image_from_other_site($mppno, $bigpicurl, 'fs_folders/images/uploads/members/mem_original/'); /* $profile_fs_src_original = 'fs_folders/images/uploads/members/mem_original'; $profile_fs_src_thumbnail = 'fs_folders/images/uploads/members/mem_thumnails'; $profile_fs_src_profilepic = 'fs_folders/images/uploads/members/mem_profile'; */ // resize the profile pic downloaded $this->resize_profile_pic_thumbnail_and_profile($mppno); // $this->resize_fb_profile_pic( $mno1 , $image , $profile_fs_src_original , $profile_fs_src_thumbnail , $profile_fs_src_profilepic ); // add activity post feed $this->add_activity_wall_post($mno1, $mppno, 'Joined', 'fs_members', $this->date_time); // redirect to the main page $_SESSION['type'] = 'new-member-fb-login'; $_SESSION['temp_mno'] = $mno1; $_SESSION['lastpagevisited'] = 'profile_crop_display.php'; $this->go('login-authentication'); } echo " ur mno {$mno1} <br> "; // add update friends on fb and on fs // updated #saving to fb_all_friends , fb_friends_on_fs , fb_friends on fb at [ user account info ] // echo "<hr>"; } else { // $b = updateArray('fs_members',array('fb_all_freinds'), array('505457421-+-549151146-+-'),'mno',$mno); // if ($b) { // echo " succesfully updated <br> "; // }else{ // echo " failled to update "; // } echo " \n\t\t\t\t\t\t\t\t <a href='{$loginUrl}'>Login with Facebook</a> \n\t\t\t\t\t\t\t\t "; // $name = $this->get_facebook_user_info_by_fbid( $facebook , '100004690904448' ); // echo " fbid = 100004690904448 and name = $name <br>"; } ?> </body> </html> <?php break; case 'twitter': # code... break; case 'google': # code... break; case 'tumblr': # code... break; default: # code... break; } }
public function testLogoutURLDefaults() { $_SERVER['HTTP_HOST'] = 'fbrell.com'; $_SERVER['REQUEST_URI'] = '/examples'; $facebook = new Facebook(array('appId' => self::APP_ID, 'secret' => self::SECRET)); $encodedUrl = rawurlencode('http://fbrell.com/examples'); $this->assertNotNull(strpos($facebook->getLogoutUrl(), $encodedUrl), 'Expect the current url to exist.'); unset($_SERVER['HTTP_HOST']); unset($_SERVER['REQUEST_URI']); }
* under the License. */ require 'facebook-php-sdk/src/facebook.php'; require 'Hash.php'; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array('appId' => '433417393393767', 'secret' => '16c4d1af1f5a1b425fdcf0630e8df7fb')); // Get User ID $user = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(array('next' => 'http://localhost/hw3/logout.php')); } else { $loginUrl = $facebook->getLoginUrl(); } // This call will always work since we are fetching public data. /* $user_id="100000100071899"; $con = mysql_connect("localhost", "root", ""); mysql_query("SET nameS utf8"); if ( ! @mysql_select_db(irpfc) ) die("無法使用資料庫"); echo""; $HFlist= new HashMap; $result =mysql_query("SELECT DISTINCT fid FROM `muflist` WHERE uid =$user_id"); while($row = mysql_fetch_array($result)){