function facebook() { global $template; $facebook = new Facebook(array('appId' => FB_APPID, 'secret' => FB_APPSECRET)); $user = $facebook->getUser(); if ($user) { try { $pages = $facebook->api('/me/accounts'); $template->set('pages', $pages); $permissions = $facebook->api("/me/permissions"); $publish_actions = 0; $manage_pages = 0; foreach ($permissions['data'] as $permission) { if ($permission['permission'] == 'publish_actions') { $publish_actions = 1; } if ($permission['permission'] == 'manage_pages') { $manage_pages = 1; } } if ($publish_actions == 0 || $manage_pages == 0) { throw new Exception("Oops"); } } catch (Exception $e) { $url = $facebook->getLoginUrl(array("scope" => "publish_actions,manage_pages")); header("Location: " . $url); exit; } } else { $url = $facebook->getLoginUrl(array("scope" => "publish_actions,manage_pages")); header("Location: " . $url); exit; } }
/** * {@inheritdoc} */ function loginBegin() { $parameters = array("scope" => $this->scope, "redirect_uri" => $this->endpoint, "display" => "page"); $optionals = array("scope", "redirect_uri", "display", "auth_type"); foreach ($optionals as $parameter) { if (isset($this->config[$parameter]) && !empty($this->config[$parameter])) { $parameters[$parameter] = $this->config[$parameter]; //If the auth_type parameter is used, we need to generate a nonce and include it as a parameter if ($parameter == "auth_type") { $nonce = md5(uniqid(mt_rand(), true)); $parameters['auth_nonce'] = $nonce; Hybrid_Auth::storage()->set('fb_auth_nonce', $nonce); } } } if (isset($this->config['force']) && $this->config['force'] === true) { $parameters['auth_type'] = 'reauthenticate'; $parameters['auth_nonce'] = md5(uniqid(mt_rand(), true)); Hybrid_Auth::storage()->set('fb_auth_nonce', $parameters['auth_nonce']); } // get the login url $url = $this->api->getLoginUrl($parameters); // redirect to facebook Hybrid_Auth::redirect($url); }
public function authenticate() { $session = Yii::app()->session; $facebook = new Facebook(array('appId' => $this->key, 'secret' => $this->secret)); $here = Yii::app()->request->hostInfo . Yii::app()->request->url; // Get User ID $user = $facebook->getUser(); // already logged in if (isset($user)) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); $session['facebook_user'] = $user_profile; $this->_authenticated = true; } catch (FacebookApiException $e) { $user = null; $params = array("scope" => "user_birthday,email,read_stream"); $loginUrl = $facebook->getLoginUrl($params); Yii::app()->request->redirect($loginUrl); } // Log in! } else { $params = array("scope" => "user_birthday,email,read_stream"); $loginUrl = $facebook->getLoginUrl($params); Yii::app()->request->redirect($loginUrl); } return $this->_authenticated; }
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')); } }
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'); } }
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 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; } }
function index() { $this->load->config('facebook'); $this->load->library('form_validation'); $this->form_validation->set_rules('fullname', 'Full Name', 'required|xss_clean'); $this->form_validation->set_rules('email', 'Email Address', 'required|valid_email'); $this->form_validation->set_rules('password', 'Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); $this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required'); 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)); $param = array('next' => site_url('/member/registration/fb')); $this->tpl['fb_login_url'] = $facebook->getLoginUrl($param); if ($this->form_validation->run() == true) { $username = strtolower($this->input->post('fullname')); $email = $this->input->post('email'); $password = $this->input->post('password'); $additional_data = array('fullname' => $this->input->post('fullname')); } if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data)) { $this->session->set_flashdata('message', "User Created"); die('redirect to sumthin lah'); } else { $this->tpl['message'] = validation_errors() ? validation_errors() : $this->ion_auth->errors(); $this->tpl['content'] = $this->load->view('registration_index', $this->tpl, true); $this->load->view('member/body', $this->tpl); } }
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; }
public function requestToken($Account) { $NGPushIni = eZINI::instance('ngpush.ini'); $SiteIni = eZINI::instance('site.ini'); $AccessToken = $NGPushIni->variable($Account, 'AccessToken'); // If access tokens are given if ($AccessToken) { //Save request signing tokens to cache ngPushBase::save_token($Account, $AccessToken, 'main_token'); } else { $AdministrationUrl = '/'; eZURI::transformURI($AdministrationUrl, false, 'full'); $AdministrationUrl = base64_encode($AdministrationUrl); $SettingsBlock = base64_encode($Account); $redirectUrl = 'http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=facebook'; $Facebook = new Facebook(array('appId' => $NGPushIni->variable($Account, 'AppAPIKey'), 'secret' => $NGPushIni->variable($Account, 'AppSecret'))); $Permissions = array('publish_actions', 'user_posts'); if ($NGPushIni->variable($Account, 'EntityType') == 'page') { $Permissions[] = 'manage_pages'; } $state = md5(uniqid(rand(), true)); $http = eZHTTPTool::instance(); $http->setSessionVariable('ngpush_state', $state); $LoginUrl = $Facebook->getLoginUrl(array('redirect_uri' => $redirectUrl, 'scope' => implode($Permissions, ','), 'state' => $state)); self::$response['RequestPermissionsUrl'] = $LoginUrl; } }
public function authorizefacebookAction() { $appId = Mage::getStoreConfig('besociable/facebook/appid'); $appSecret = Mage::getStoreConfig('besociable/facebook/appsecret'); $pageId = Mage::getStoreConfig('besociable/facebook/pageid'); if ($appId != '' && $appSecret != '') { $facebook = new Facebook(array('appId' => $appId, 'secret' => $appSecret)); $user = $facebook->getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me', 'GET', array('ref' => 'fbwpp')); } catch (FacebookApiException $e) { Mage::getSingleton("adminhtml/session")->addError(Mage::helper("sociable")->__("Cannot login! Please double check your data!")); $user = null; } } else { Mage::getSingleton("adminhtml/session")->addError(Mage::helper("sociable")->__("Please enter your facebook app info!")); } if ($user) { Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("sociable")->__("You have successfully authorized with facebook.")); $this->_redirect("*/system_config/edit/section/besociable/"); } else { try { $loginUrl = $facebook->getLoginUrl(array('scrope' => array('manage_pages', 'publish_actions', 'publish_stream'))); $this->_redirect($loginUrl); } catch (Exception $ex) { Mage::getSingleton("adminhtml/session")->addError(Mage::helper("sociable")->__("Cannot login! Please double check your data!")); } } } else { Mage::getSingleton("adminhtml/session")->addError(Mage::helper("sociable")->__("Please enter your facebook app info!")); } $this->_redirect("*/system_config/edit/section/besociable/"); }
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 } }
/** * Renders the bookmarklet when it is opened. Gets the URL of the item being ingested through the Request container, * sends it to the parser and renders the result on the bookmarklet if it can be ingested or an error otherwise. * * @return Response * */ public function openAction() { $request = $this->getRequest(); $session = $request->getSession(); // get logged user $user = $this->get('security.context')->getToken()->getUser(); $widgetId = $request->query->get('widget-id'); $itemUrl = $request->query->get('url'); $parserResponse = $this->forward('ZeegaApiBundle:Items:getItemsParser', array(), array("url" => $itemUrl))->getContent(); $parserResponse = json_decode($parserResponse, true); $message = "SORRY! We can't add this item."; if (isset($parserResponse)) { //var_dump($parserResponse); $isUrlValid = $parserResponse["request"]["parser"]["success"]; $isUrlCollection = $parserResponse["request"]["parser"]["is_set"]; $message = $parserResponse["request"]["parser"]["message"]; $items = $parserResponse["items"]; if ($isUrlValid && count($items) > 0) { $parsedItem = $items[0]; // check if the item exists on the database $item = $this->getDoctrine()->getRepository('ZeegaDataBundle:Item')->findOneBy(array("user" => $user->getId(), "attributionUri" => $parsedItem["attribution_uri"], "enabled" => 1)); if (isset($item)) { $update = 1; $parsedItem["id"] = $item->getId(); } else { $update = 0; } if ($parsedItem["archive"] == "Dropbox") { if (!$update && $parsedItem["child_items_count"] == 0) { // Dropbox - welcome screen for the initial connection with dropbox return $this->render('ZeegaBookmarkletBundle:Bookmarklet:dropboxwelcome.widget.html.twig', array('displayname' => $user->getDisplayname(), 'widget_id' => $widgetId, 'item' => json_encode($parsedItem), 'update' => $update, 'child_items_count' => $parsedItem["child_items_count"], 'archive' => $parsedItem["archive"])); } } else { if ($parsedItem["archive"] == "Facebook") { // Facebook - needs to be loaded in a pop-up if ($parsedItem["child_items_count"] == -1) { // no access token. overloading child_items_count is a hack. Find cleaner way soon. //header('X-Frame-Options: Allow'); $requirePath = __DIR__ . '/../../../../vendor/facebook/facebook.php'; require_once $requirePath; $facebook = new \Facebook(array('appId' => '459848834048078', 'secret' => 'f5b344b91bff03ace4df454e35fca4e4')); $loginUrlParams = array('scope' => 'user_photos,friends_photos', 'display' => 'popup'); $loginUrl = $facebook->getLoginUrl($loginUrlParams); return $this->render('ZeegaBookmarkletBundle:Bookmarklet:facebookWelcome.widget.html.twig', array('displayname' => $user->getDisplayname(), 'widget_id' => $widgetId, 'item' => json_encode($parsedItem), 'update' => $update, 'archive' => $parsedItem["archive"], 'child_items_count' => $parsedItem["child_items_count"], 'login_url' => $loginUrl)); } else { // access token return $this->render('ZeegaBookmarkletBundle:Bookmarklet:widget.html.twig', array('displayname' => $user->getDisplayname(), 'widget_id' => $widgetId, 'item' => json_encode($parsedItem), 'update' => $update, 'archive' => $parsedItem["archive"], 'thumbnail_url' => $parsedItem["thumbnail_url"], 'child_items_count' => $parsedItem["child_items_count"])); } } else { if ($update) { return $this->render('ZeegaBookmarkletBundle:Bookmarklet:duplicate.widget.html.twig', array('displayname' => $user->getDisplayname(), 'widget_id' => $widgetId, 'item' => $item, 'update' => $update, 'archive' => $parsedItem["archive"])); } } } // for all other cases return $this->render('ZeegaBookmarkletBundle:Bookmarklet:widget.html.twig', array('displayname' => $user->getDisplayname(), 'widget_id' => $widgetId, 'item' => json_encode($parsedItem), 'update' => $update, 'archive' => $parsedItem["archive"], 'thumbnail_url' => $parsedItem["thumbnail_url"], 'child_items_count' => $parsedItem["child_items_count"])); } } return $this->render('ZeegaBookmarkletBundle:Bookmarklet:fail.widget.html.twig', array('displayname' => $user->getDisplayname(), 'widget_id' => $widgetId, 'item' => json_encode(array()), 'urlmessage' => $message, 'url' => $itemUrl, 'archive' => "")); }
public function get_user_data_fb() { parse_str($_SERVER['QUERY_STRING'], $_REQUEST); $facebook = new Facebook(array('appId' => '876274572459160', 'secret' => 'c44768470ff9f9d7a52784f6f5fbfd9a', 'cookie' => true, 'redirect_uri' => 'kepoabis.com')); Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false; Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2; $user = $facebook->getUser(); $user_data = array(); if ($user) { try { $user_data = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } $url = ""; $img = ""; if ($user) { $url = "<strong><em>You are connected with Facebook.<br></em></strong>"; //$facebook->getLogoutUrl(); $img = "https://graph.facebook.com/" . $user . "/picture"; } else { $url = "<a class='btn btn-default btn-social btn-facebook' href=" . $facebook->getLoginUrl() . "><i class='fa fa-facebook'></i>Sign in with Facebook</a>"; } return array("url" => $url, "img" => $img, "is_login" => $user, "user_data" => $user_data); }
public static function getFacebookLoginUrl() { if (is_object(self::$object)) { return self::$object->getLoginUrl(array('scope' => implode(',', self::$aPermissionFields))); } return false; }
public function fbc_friend() { global $context, $fbuser, $Url, $FacebookId, $fb_hook_object, $friends, $scripturl, $fb_object, $curOffset; $context['sub_template'] = 'fbc_friends'; $context['fb_do'] = 'friends'; SAFacebookhooks::face_init(); $facebook = new Facebook(array('appId' => $fb_hook_object->modSettings['fb_app_id'], 'secret' => $fb_hook_object->modSettings['fb_app_secret'])); $Url = $facebook->getLoginUrl(array('redirect_uri' => $scripturl . '?action=facebook', 'scope' => 'email,publish_actions')); $fb_object->fbc_cons_pages('friends', 32); if (!$fb_hook_object->modSettings['fb_mode2']) { redirectexit(); } $fbuser = $FacebookId; if ($fbuser) { //Try it!!!!! try { //These api calls can be slow so were only do it if needed if (empty($_SESSION['safbfriends'][$curOffset])) { $_SESSION['safbfriends'][$curOffset] = $facebook->api('/me/friends?offset=' . $curOffset . '&limit=32'); } $friends = $_SESSION['safbfriends'][$curOffset]; } catch (FacebookApiException $e) { //Throw it!!!!! fatal_error($e, false); } } }
public function actionFacebook() { require_once 'facebook/facebook.php'; $facebook = new Facebook(array('appId' => Yii::app()->params['facebookAppId'], 'secret' => Yii::app()->params['facebookSecretCode'], 'cookie' => true)); $user = $facebook->getUser(); if (isset($_POST['Member']['memberid'])) { $memberdata = Member::model()->getMemberById($_POST['Member']['memberid']); $this->actMemberinfo($memberdata, '', '', '', 'facebook', ''); } else { if (!empty($user)) { //Active session, let's try getting the user id (getUser()) and user info (api->('/me')) try { //$facebookuserid = $facebook->getUser(); $facebookuser = $facebook->api('/me'); //print_r($facebookuser); } catch (FacebookApiException $e) { error_log($e); } if (!empty($facebookuser)) { $memberdata = Member::model()->getMemberByOauth($facebookuser['id']); $this->actMemberinfo($memberdata, '', '', $facebookuser, 'facebook', ''); } else { //For testing purposes, if there was an error, let's kill the script die("There was an error."); } } else { //There's no active session, let's generate one $login_url = $facebook->getLoginUrl(array('scope' => 'email')); // echo $login_url; header("Location: " . $login_url); } } }
public function process_request($request) { if ($request == 'facebook-login') { $app_id = qa_opt('facebook_app_id'); $app_secret = qa_opt('facebook_app_secret'); $tourl = qa_get('to'); if (!strlen($tourl)) { $tourl = qa_path_absolute(''); } if (strlen($app_id) && strlen($app_secret)) { require_once $this->directory . 'facebook.php'; $facebook = new Facebook(array('appId' => $app_id, 'secret' => $app_secret, 'cookie' => true)); $fb_userid = $facebook->getUser(); if ($fb_userid) { try { $user = $facebook->api('/me?fields=email,name,verified,location,website,about,picture.width(250)'); if (is_array($user)) { qa_log_in_external_user('facebook', $fb_userid, array('email' => @$user['email'], 'handle' => @$user['name'], 'confirmed' => @$user['verified'], 'name' => @$user['name'], 'location' => @$user['location']['name'], 'website' => @$user['website'], 'about' => @$user['bio'], 'avatar' => strlen(@$user['picture']['data']['url']) ? qa_retrieve_url($user['picture']['data']['url']) : null)); } } catch (FacebookApiException $e) { } } else { qa_redirect_raw($facebook->getLoginUrl(array('redirect_uri' => $tourl))); } } qa_redirect_raw($tourl); } }
/** * Function for check login * */ public function login() { // Setting the page title $this->set("title_for_layout", "User Login"); if ($this->Auth->login()) { $this->redirect($this->Auth->redirect()); } else { if ($this->request->is('post')) { $this->Session->setFlash(__('Invalid username or password, try again')); } } $facebooksecretkey = '4753a9042404a78aaff1069f73aa8994'; $facebookapikey = '203755806382341'; App::import('Vendor', 'facebook', array('file' => 'facebook/src/facebook.php')); $facebook = new Facebook(array('appId' => "{$facebookapikey}", 'secret' => "{$facebooksecretkey}")); $user = $facebook->getUser(); $facebookLoginUrl = $facebook->getLoginUrl(); $this->set('facebookLoginUrl', $facebookLoginUrl); if ($user) { $faceBookUserProfile = $facebook->api('/me'); if (isset($faceBookUserProfile) && !empty($faceBookUserProfile)) { $this->facebook($faceBookUserProfile); } } //ends here }
static function facebook_login_link() { $appid = MObject::get('preference', 'facebook_app_id'); $secret = MObject::get('preference', 'facebook_secret'); $scope = array('scope' => 'user_events'); $facebook = new Facebook(array('appId' => $appid->get_value(), 'secret' => $secret->get_value(), 'allowSignedRequest' => false)); return $facebook->getLoginUrl($scope); }
public function getLoginUrl() { $this->load(); $params = array(); if ($this->redirectUri) { $params['redirect_uri'] = $this->redirectUri; } return $this->facebook->getLoginUrl($params); }
function loginByOpenID() { $post = $_POST; $get = $_GET; $request = $_REQUEST; $site = $this->siteUrl(); $callBackUrl = $this->callBackUrl(); $response = new stdClass(); $a = explode('_', $this->get_var(parent::$loginKey)); $action = $a[1]; $options = $this->getOptions(); $config = array('appId' => $options['facebook_key'], 'secret' => $options['facebook_secret']); $facebook = new Facebook($config); if ($action == 'login') { $loginUrl = $facebook->getLoginUrl(array('redirect_uri' => $callBackUrl . parent::$loginKey . '=' . self::$loginBy . '_check', 'scope' => 'email')); $this->redirect($loginUrl); exit; } else { echo "jay"; die; $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 != null) { $response->status = 'SUCCESS'; $response->deuid = $user_profile['id']; $response->deutype = 'facebook'; $response->first_name = $user_profile['first_name']; $response->last_name = $user_profile['last_name']; $response->email = $user_profile['email']; $response->username = $user_profile['email']; ////['id'].'@facebook'; $headers = get_headers('https://graph.facebook.com/' . $user_profile['id'] . '/picture', 1); // just a precaution, check whether the header isset... if (isset($headers['Location'])) { $response->deuimage = $headers['Location']; // string } else { $response->deuimage = false; // nothing there? .. weird, but okay! } $response->error_message = ''; } else { $response->status = 'ERROR'; $response->error_code = 2; $response->error_message = 'INVALID AUTHORIZATION'; } } return $response; }
public function getLoginUrl($params = array()) { if (!is_array($params)) { $params = array(); } if (!isset($params['req_perms'])) { $params['req_perms'] = $this->_getStdPermList(); } return parent::getLoginUrl($params); }
/** * Facebook login */ public function actionlogin() { require_once Yii::app()->basePath . '/vendor/facebook-php-sdk/src/facebook.php'; $facebook = new Facebook(array('appId' => '894567207287021', 'secret' => 'cf43d6c081acaed16c908cac9d49bc07')); $fbUser = $facebook->getUser(); $loginUrl = $facebook->getLoginUrl(array('redirect_uri' => "http://localhost/olx/index.php?r=/social/listing", 'cancel_uri' => '', 'scope' => 'email,user_likes')); $this->redirect($loginUrl); die; $this->render('login', array('data' => array('facebook' => $facebook))); }
/** * * @var array */ public function getLoginUrl($params = array()) { if (!isset($params['redirect_uri'])) { $params['redirect_uri'] = \Config::get('facebook-connect::redirect_uri'); } if (!isset($params['scope'])) { $params['scope'] = \Config::get('facebook-connect::scope'); } return parent::getLoginUrl($params); }
/** * Render fieldset html * * @param Varien_Data_Form_Element_Abstract $element * @return string */ public function render(Varien_Data_Form_Element_Abstract $element) { $msg = '<div style="padding-bottom: 1em;max-width: 800px;">'; $appId = Mage::getStoreConfig('besociable/facebook/appid'); $appSecret = Mage::getStoreConfig('besociable/facebook/appsecret'); $currentAccessToken = Mage::getStoreConfig('besociable/facebook/access_token'); if ($appId != '' && $appSecret != '') { $facebook = new Facebook(array('appId' => $appId, 'secret' => $appSecret)); $merge = $appId . '|' . $appSecret; $accessToken = $facebook->getAccessToken(); if ($accessToken != $merge && $accessToken != $currentAccessToken) { Mage::getConfig()->saveConfig('besociable/facebook/access_token', $accessToken); $facebook->setAccessToken($accessToken); } else { $facebook->setAccessToken($currentAccessToken); } $user = $facebook->getUser(); if ($user) { $loginUrl = $facebook->getLoginUrl(array('scope' => array('manage_pages', 'publish_stream'))); $msg .= Mage::helper('sociable')->__('<span style="color: green;">You have successfully authorized with facebook.</span>'); $msg .= Mage::helper('sociable')->__('<br>You can always <a href="%s">click here</a> to re-authorize your access to facebook again.', $loginUrl); $msg .= Mage::helper('sociable')->__('<br>If you want to get a list of your pages, you can simply <a href="%s">click here</a>', $this->getUrl('adminhtml/sociable/getPages')); $msg .= Mage::helper('sociable')->__('<br>Please <a href="%s">click here</a> to make a test post.', $this->getUrl('adminhtml/sociable/testfacebook')); /* if(!$user){ $loginUrl = $facebook->getLoginUrl(array('scope'=>array('manage_pages','publish_stream')));//, 'publish_actions', 'publish_stream' $msg .= Mage::helper('sociable')->__('<strong style="color:red">Important: </strong>'); $msg .= Mage::helper('sociable')->__('You will need to <a href="%s">click here</a> to authorize your access to facebook for the first time.',$loginUrl); }else { } */ } else { $loginUrl = $facebook->getLoginUrl(array('scope' => array('manage_pages', 'publish_stream'))); //, 'publish_actions', 'publish_stream' $msg .= Mage::helper('sociable')->__('<strong style="color:red">Important: </strong>'); $msg .= Mage::helper('sociable')->__('You will need to <a href="%s">click here</a> to authorize your access to facebook for the first time.', $loginUrl); } } $msg .= '</div>'; return $msg; }
function estate_facebook_login($get_vars) { require get_template_directory() . '/libs/resources/facebook.php'; $facebook_api = esc_html(get_option('wp_estate_facebook_api', '')); $facebook_secret = esc_html(get_option('wp_estate_facebook_secret', '')); $facebook = new Facebook(array('appId' => $facebook_api, 'secret' => $facebook_secret, 'cookie' => true)); $secret = $facebook_secret; $params = array('redirect_uri' => wpestate_get_dashboard_profile_link(), 'scope' => 'email'); $login_url = $facebook->getLoginUrl($params); $user_id = $facebook->getUser(); if ($user_id == 0) { $login_url = $facebook->getLoginUrl($params); wp_redirect($login_url); } else { $user_profile = $facebook->api('/me', 'GET'); if (isset($user_profile['last_name'])) { $full_name = $user_profile['first_name'] . $user_profile['last_name']; } if (isset($user_profile['name'])) { $full_name = $user_profile['name']; } if (isset($user_profile['email'])) { $email = $user_profile['email']; } else { $email = $full_name . '@facebook.com'; } $identity_code = $secret . $user_profile['id']; wpestate_register_user_via_google($email, $full_name, $identity_code); $info = array(); $info['user_login'] = $full_name; $info['user_password'] = $identity_code; $info['remember'] = true; $user_signon = wp_signon($info, false); if (is_wp_error($user_signon)) { wp_redirect(esc_url(home_url())); } else { wpestate_update_old_users($user_signon->ID); wp_redirect(wpestate_get_dashboard_profile_link()); } } }
/** * Set user login url */ protected function setLoginUrl() { // Set the default redirect uri $this->setRedirectUri(); // Add request id's to the end of the login url if (!empty($_REQUEST['request_ids'])) { $this->redirectUri .= strpos($this->redirectUri, '?') === false ? '?' : '&'; $this->redirectUri .= 'request_ids=' . $_REQUEST['request_ids']; } // Set the login url $this->loginUrl = $this->sdk->getLoginUrl(array('scope' => isset($this->config['appPerms']) ? $this->config['appPerms'] : '', 'redirect_uri' => $this->redirectUri)); }
/** Facebook */ public function getFbLoginUrl() { try { if (!class_exists('Facebook')) { require_once Mage::getBaseDir('lib') . DS . 'Facebookv3' . DS . 'facebook.php'; } $facebook = new Facebook(array('appId' => $this->_getHelper()->getReferConfig('fbapp_id'), 'secret' => $this->_getHelper()->getReferConfig('fbapp_secret'), 'cookie' => true)); $loginUrl = $facebook->getLoginUrl(array('display' => 'popup', 'redirect_uri' => $this->getUrl('*/*/facebook', array('auth' => 1)), 'scope' => 'publish_stream,email')); return $loginUrl; } catch (Exception $e) { } }
/** * Fetch the HTML for the button * * @param string $type Unused string. * @param string $name The name of the button icon class. * @param string $text Button text. * @param string $task Task associated with the button. * @param boolean $list True to allow lists * * @return string HTML string for the button * * @since 3.0 */ public function fetchButton($type = 'J2FBPost', $name = '', $text = '', $task = '', $list = false) { $class = $this->fetchIconClass($name); if ($name == "apply" || $name == "new") { $btnClass = "btn btn-small btn-success"; $iconWhite = "icon-white"; } else { $btnClass = "btn btn-small"; $iconWhite = ""; } JFactory::getDocument()->addStyleDeclaration('div#toolbar div#toolbar-' . $name . ' button.btn i.icon-' . $name . '-login::before {color: #2F96B4;content: "\\"";}'); JFactory::getDocument()->addStyleDeclaration('div#toolbar div#toolbar-' . $name . ' button.btn i.icon-' . $name . '::before {color: #2F96B4;content: "&";}'); JFactory::getDocument()->addStyleDeclaration('div#toolbar div#toolbar-' . $name . ' button.btn i.icon-' . $name . '-waiting::before {color: #2F96B4;content: "j";}'); // Create our Application instance $facebook = new Facebook(array('appId' => self::$appid, 'secret' => self::$secret, 'cookie' => true)); if ($fbuser = $facebook->getUser()) { try { $user_profile = $facebook->api('/me'); //Get user pages details using Facebook Query Language (FQL) $fql_query = 'SELECT page_id, name, page_url FROM page WHERE page_id IN (SELECT page_id FROM page_admin WHERE uid=' . $fbuser . ')'; $postResults = $facebook->api(array('method' => 'fql.query', 'query' => $fql_query)); } catch (FacebookApiException $e) { JError::raiseWarning(1, $e->getMessage()); return null; } } else { //Show login button for guest users $i18n_text = JText::_('Login'); $doTask = $facebook->getLoginUrl(array('redirect_uri' => JURI::current(), 'scope' => 'publish_stream,read_stream,offline_access,manage_pages')); /* * publish_stream – allows the application to publish updates to Facebook on the user’s behalf * read_stream – allows the application to read from the user’s News Feed * offline_access – converts the access_token to one that doesn’t expire, thus letting the application make API calls anytime. Without this, the application’s access_token will expire after a few minutes, which isn’t ideal in this case * manage_pages – lets the application access the user’s Facebook Pages. Since the application we’re building deals with Facebook Pages, we’ll need this as well. */ $html = "<button class=\"btn btn-small\" onclick=\"location.href='{$doTask}';\">\n"; $html .= "<i class=\"{$class}-login\">\n"; $html .= "</i>\n"; $html .= "{$i18n_text}\n"; $html .= "</button>\n"; } if ($fbuser && $postResults) { $i18n_text = JText::_($text); $doTask = $this->_getCommand($name, $task, $list); $doc = JFactory::getDocument(); $doc->addScript("../media/lib_eshiol_core/js/encryption.js"); $doc->addScript("../media/lib_eshiol_core/js/core.js"); foreach ($postResults as $item) { $options[] = array('text' => $item['name'], 'value' => $item['page_id']); } array_unshift($options, JHTML::_('select.option', 0, '- Select a page -')); $html = "<button data-toggle=\"modal\" data-target=\"#collapseModal{$name}\" class=\"" . $btnClass . "\">\n"; $html .= "<i class=\"{$class} {$iconWhite}\">\n"; $html .= "</i>\n"; $html .= "{$i18n_text}\n"; $html .= "</button>\n"; $html .= "\r\n<div class=\"modal hide fade\" id=\"collapseModal{$name}\">\r\n\t<div class=\"modal-header\">\r\n\t\t<button type=\"button\" class=\"close\" data-dismiss=\"modal\">x</button>\r\n\t\t<h3>Post to Facebook</h3>\r\n\t</div>\r\n\t<div class=\"modal-body\" style=\"min-height:250px\">\r\n\t\t<p>Post to facebook using www.eshiol.it app</p>\r\n\t\t<div class=\"control-group\">\r\n\t\t\t<div class=\"controls\">" . JHtml::_('select.genericlist', $options, 'fbpage', array('list.attr' => 'class="inputbox" size="1"', 'list.select' => 0)) . "\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</div>\r\n\t<div class=\"modal-footer\">\r\n\t\t<button class=\"btn\" type=\"button\" onclick=\"document.id('fbpage').value=''\" data-dismiss=\"modal\">\r\n\t\t\t" . JText::_('JCANCEL') . "\r\n\t\t</button>\r\n\t\t<button class=\"btn btn-primary\" type=\"button\" onclick=\"{$doTask}\">\r\n\t\t\t{$i18n_text}\r\n\t\t</button>\r\n\t</div>\r\n</div>\r\n\t\t\t"; } return $html; }