Ejemplo n.º 1
0
 private function _startLinkedinHandshake($req_type, $credentials)
 {
     $session = self::oauth_session_exists();
     $app = JFactory::getApplication();
     require_once dirname(__FILE__) . DS . 'jobboard' . DS . 'lib' . DS . 'linkedin' . DS . 'linkedin_3.1.1.class.php';
     $API_CONFIG = array('appKey' => $credentials['key'], 'appSecret' => $credentials['secret'], 'callbackUrl' => null);
     switch ($req_type) {
         case 'initiate':
             $API_CONFIG['callbackUrl'] = JURI::root() . 'index.php?option=com_jobboard&view=user&task=getlinkedinprof&' . $req_type . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1&Itemid=' . $this->_itemid;
             $OBJ_linkedin = new LinkedIn($API_CONFIG);
             $_GET[LINKEDIN::_GET_RESPONSE] = isset($_GET[LINKEDIN::_GET_RESPONSE]) ? $_GET[LINKEDIN::_GET_RESPONSE] : '';
             if (!$_GET[LINKEDIN::_GET_RESPONSE]) {
                 $response = $OBJ_linkedin->retrieveTokenRequest();
                 if ($response['success'] === TRUE) {
                     $session_oauth = $session->get('oauth');
                     $session_oauth['oauth']['linkedin']['request'] = $response['linkedin'];
                     $session->set('oauth', $session_oauth);
                     $app->redirect(LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
                 } else {
                     $msg = JText::_('PLG_JOBBOARD_REQUEST_TOKEN_RETRIEVAL_FAILED');
                     $app->redirect('index.php?option=com_jobboard&view=user&task=addcv&Itemid=' . $this->_itemid, $msg, 'error');
                 }
             } else {
                 self::_processResponse(&$OBJ_linkedin);
             }
             return self::_getLinkedInProfile(&$OBJ_linkedin);
             break;
         case 'revoke':
             $session_oauth = $session->get('oauth');
             $OBJ_linkedin = new LinkedIn($API_CONFIG);
             $OBJ_linkedin->setTokenAccess($session_oauth['oauth']['linkedin']['access']);
             $response = $OBJ_linkedin->revoke();
             if ($response['success'] === TRUE) {
                 if ($session->clear('oauth')) {
                     $msg = JText::_('PLG_JOBBOARD_AUTH_REVOKE_SUCCESS');
                     $msg_type = 'Message';
                 } else {
                     $msg = JText::_('PLG_JOBBOARD_SESSION_CLEAR_FAILED');
                     $msg_type = 'error';
                 }
             } else {
                 $msg = JText::_('PLG_JOBBOARD_AUTH_REVOKE_FAILED');
                 $msg_type = 'error';
             }
             $app->redirect('index.php?option=com_jobboard&view=user&task=addcv&Itemid=' . $this->_itemid, $msg, $msg_type);
             break;
         default:
             break;
     }
 }
Ejemplo n.º 2
0
             // bad token access
             echo "Access token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
         }
     }
     break;
 case 'revoke':
     /**
      * Handle authorization revocation.
      */
     // check the session
     if (!oauth_session_exists()) {
         throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
     }
     $OBJ_linkedin = new LinkedIn($API_CONFIG);
     $OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
     $response = $OBJ_linkedin->revoke();
     if ($response['success'] === TRUE) {
         // revocation successful, clear session
         session_unset();
         $_SESSION = array();
         if (session_destroy()) {
             // session destroyed
             header('Location: ' . $_SERVER['PHP_SELF']);
         } else {
             // session not destroyed
             echo "Error clearing user's session";
         }
     } else {
         // revocation failed
         echo "Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
     }
 function index()
 {
     $API_CONFIG = $this->config->item('LINKEDIN_KEYS');
     define('DEMO_GROUP', '4010474');
     define('DEMO_GROUP_NAME', 'Simple LI Demo');
     define('PORT_HTTP', '80');
     define('PORT_HTTP_SSL', '443');
     $_REQUEST[LINKEDIN::_GET_TYPE] = isset($_REQUEST[LINKEDIN::_GET_TYPE]) ? $_REQUEST[LINKEDIN::_GET_TYPE] : '';
     switch ($_REQUEST[LINKEDIN::_GET_TYPE]) {
         case 'initiate':
             // check for the correct http protocol (i.e. is this script being served via http or https)
             if ($this->input->server('HTTPS') == 'on') {
                 $protocol = 'https';
             } else {
                 $protocol = 'http';
             }
             // set the callback url
             $API_CONFIG['callbackUrl'] = $protocol . '://' . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != PORT_HTTP || $_SERVER['SERVER_PORT'] != PORT_HTTP_SSL ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF'] . '?' . LINKEDIN::_GET_TYPE . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1';
             $OBJ_linkedin = new LinkedIn($API_CONFIG);
             // check for response from LinkedIn
             $_GET[LINKEDIN::_GET_RESPONSE] = isset($_GET[LINKEDIN::_GET_RESPONSE]) ? $_GET[LINKEDIN::_GET_RESPONSE] : '';
             if (!$_GET[LINKEDIN::_GET_RESPONSE]) {
                 // LinkedIn hasn't sent us a response, the user is initiating the connection
                 // send a request for a LinkedIn access token
                 $response = $OBJ_linkedin->retrieveTokenRequest();
                 if ($response['success'] === TRUE) {
                     // store the request token
                     //$_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];
                     $response['linkedin']['request'] = $response['linkedin'];
                     $this->session->set_userdata($response['linkedin']);
                     // redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
                     header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
                 } else {
                     // bad token request
                     echo "Request token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
                 }
             } else {
                 $sess = $this->session->all_userdata();
                 // LinkedIn has sent a response, user has granted permission, take the temp access token, the user's secret and the verifier to request the user's real secret key
                 $response = $OBJ_linkedin->retrieveTokenAccess($sess['request']['oauth_token'], $sess['request']['oauth_token_secret'], $_GET['oauth_verifier']);
                 //$response = $OBJ_linkedin->retrieveTokenAccess($_SESSION['oauth']['linkedin']['request']['oauth_token'], $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']);
                 if ($response['success'] === TRUE) {
                     // the request went through without an error, gather user's 'access' tokens
                     //$sess['access'] = $response['linkedin'];
                     $this->session->set_userdata('access', $response['linkedin']);
                     $this->session->set_userdata('authorized', TRUE);
                     // set the user as authorized for future quick reference
                     //save the shit to the db
                     $OBJ_linkedin = new LinkedIn($API_CONFIG);
                     $OBJ_linkedin->setTokenAccess($this->session->userdata('access'));
                     $OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_JSON);
                     $userResponse = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url,email-address)');
                     if ($userResponse['success'] === TRUE) {
                         $userData = json_decode($userResponse['linkedin'], true);
                         $this->load->model('user');
                         $this->load->model('billing');
                         if (!$this->user->exist($userData['id'])) {
                             $userId = $this->user->create($userData);
                             $userId = $this->billing->create(FALSE, $userId);
                             $this->session->set_userdata('user_id', $userId);
                         } else {
                             $user = $this->user->get_by_id($userData['id']);
                             $this->session->set_userdata('user_id', $user[0]->id);
                         }
                     }
                     redirect('/builder/get_resume_data', 'refresh');
                     // redirect the user back to the demo page
                     //header('Location: ' . $_SERVER['PHP_SELF']);
                 } else {
                     echo "Access token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
                 }
             }
             break;
         case 'revoke':
             // check the session
             /*
             if(!$this->oauth_session_exists()) {
               throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
             }
             */
             $OBJ_linkedin = new LinkedIn($API_CONFIG);
             $OBJ_linkedin->setTokenAccess($this->session->userdata('access'));
             $response = $OBJ_linkedin->revoke();
             if ($response['success'] === TRUE) {
                 // revocation successful, clear session
                 $this->session->sess_destroy();
                 redirect('/marketing', 'refresh');
             } else {
                 // revocation failed
                 echo "Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
             }
             break;
         default:
     }
     $isLoggedIn = $this->session->userdata('authorized') ? $this->session->userdata('authorized') : FALSE;
     if ($isLoggedIn) {
         redirect('/builder/get_resume_data', 'refresh');
     }
     $this->load->model('resume');
     $resumeData = $this->resume->get_by_id(1);
     $resumeJsonData = json_encode($resumeData);
     $viewData = array('isLoggedIn' => $isLoggedIn, 'json_data' => $resumeJsonData);
     $this->load->view('marketing/home', $viewData);
 }
Ejemplo n.º 4
0
 public function linkedin()
 {
     try {
         $API_CONFIG = array('appKey' => '75wpz389ifrzbq', 'appSecret' => 'ZYEG6gBlFhhUAkfR', 'callbackUrl' => NULL);
         define('DEMO_GROUP', '4010474');
         define('DEMO_GROUP_NAME', 'Simple LI Demo');
         define('PORT_HTTP', '80');
         define('PORT_HTTP_SSL', '443');
         $_GET['lType'] = isset($_GET['lType']) ? $_GET['lType'] : '';
         switch ($_GET['lType']) {
             case 'initiate':
                 if ($_SERVER['HTTPS'] == 'on') {
                     $protocol = 'https';
                 } else {
                     $protocol = 'http';
                 }
                 $API_CONFIG['callbackUrl'] = $protocol . '://' . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != PORT_HTTP || $_SERVER['SERVER_PORT'] != PORT_HTTP_SSL ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF'] . '?' . LINKEDIN::_GET_TYPE . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1';
                 $OBJ_linkedin = new LinkedIn($API_CONFIG);
                 $_GET[LINKEDIN::_GET_RESPONSE] = isset($_GET[LINKEDIN::_GET_RESPONSE]) ? $_GET[LINKEDIN::_GET_RESPONSE] : '';
                 if (!$_GET[LINKEDIN::_GET_RESPONSE]) {
                     $response = $OBJ_linkedin->retrieveTokenRequest();
                     if ($response['success'] === TRUE) {
                         $_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];
                         header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
                     } else {
                         echo "Request token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
                     }
                 } else {
                     $response = $OBJ_linkedin->retrieveTokenAccess($_SESSION['oauth']['linkedin']['request']['oauth_token'], $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']);
                     if ($response['success'] === TRUE) {
                         $_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
                         $_SESSION['oauth']['linkedin']['authorized'] = TRUE;
                         header('Location: ' . $_SERVER['PHP_SELF']);
                     } else {
                         echo "Access token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
                     }
                 }
                 break;
             case 'revoke':
                 if (!oauth_session_exists()) {
                     throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
                 }
                 $OBJ_linkedin = new LinkedIn($API_CONFIG);
                 $OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
                 $response = $OBJ_linkedin->revoke();
                 if ($response['success'] === TRUE) {
                     session_unset();
                     $_SESSION = array();
                     if (session_destroy()) {
                         header('Location: ' . $_SERVER['PHP_SELF']);
                     } else {
                         echo "Error clearing user's session";
                     }
                 } else {
                     echo "Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
                 }
                 break;
             default:
                 $_SESSION['oauth']['linkedin']['authorized'] = isset($_SESSION['oauth']['linkedin']['authorized']) ? $_SESSION['oauth']['linkedin']['authorized'] : FALSE;
                 if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
                     $OBJ_linkedin = new LinkedIn($API_CONFIG);
                     $OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
                     $OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_XML);
                     $response = $OBJ_linkedin->group(DEMO_GROUP, ':(relation-to-viewer:(membership-state))');
                     if ($response['success'] === TRUE) {
                         $result = new SimpleXMLElement($response['linkedin']);
                         $membership = $result->{'relation-to-viewer'}->{'membership-state'}->code;
                         $in_demo_group = $membership == 'non-member' || $membership == 'blocked' ? FALSE : TRUE;
                     } else {
                         echo "Error retrieving group membership information: <br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre>";
                     }
                 } else {
                 }
                 if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
                     $response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url)');
                     if ($response['success'] === TRUE) {
                         $response['linkedin'] = new SimpleXMLElement($response['linkedin']);
                         echo "<pre>" . print_r($response['linkedin'], TRUE) . "</pre>";
                     } else {
                         echo "Error retrieving profile information:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>";
                     }
                 } else {
                 }
                 break;
         }
     } catch (LinkedInException $e) {
         echo $e->getMessage();
     }
     $this->setErrorMessage('success', 'Registered & Login Successfully');
 }
Ejemplo n.º 5
0
 public function revokeApp()
 {
     $result = parent::revoke();
     return $result['success'] == true;
 }
Ejemplo n.º 6
0
    function getLinkedinProfile($req_type)
    {
        $session = LinkedinHelper::oauth_session_exists();
        $app = JFactory::getApplication();
        // include the LinkedIn class
        require_once 'linkedin_3.1.1.class.php';
        // display constants
        $API_CONFIG = array('appKey' => 'r7xckk3gxdfg', 'appSecret' => 'fJQh57Ex2Qg7YyPi', 'callbackUrl' => NULL);
        define('CONNECTION_COUNT', 20);
        define('PORT_HTTP', '80');
        define('PORT_HTTP_SSL', '443');
        define('UPDATE_COUNT', 10);
        // set index
        //$_REQUEST[LINKEDIN::_GET_TYPE] = (isset($_REQUEST[LINKEDIN::_GET_TYPE])) ? $_REQUEST[LINKEDIN::_GET_TYPE] : '';
        switch ($req_type) {
            case 'initiate':
                /**
                 * Handle user initiated LinkedIn connection, create the LinkedIn object.
                 */
                // check for the correct http protocol (i.e. is this script being served via http or https)
                if (isset($_SERVER['HTTPS'])) {
                    if ($_SERVER['HTTPS'] == 'on') {
                        $protocol = 'https';
                    } else {
                        $protocol = 'http';
                    }
                } else {
                    $protocol = 'http';
                }
                // set the callback url
                $API_CONFIG['callbackUrl'] = $protocol . '://' . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != PORT_HTTP || $_SERVER['SERVER_PORT'] != PORT_HTTP_SSL ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF'] . '?' . $req_type . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1';
                // $API_CONFIG['callbackUrl'] = JRoute::_('index.php?option=com_jobboard&view=user') . '&' . $req_type . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1';
                //  echo $API_CONFIG['callbackUrl'];die;
                $OBJ_linkedin = new LinkedIn($API_CONFIG);
                // check for response from LinkedIn
                $_GET[LINKEDIN::_GET_RESPONSE] = isset($_GET[LINKEDIN::_GET_RESPONSE]) ? $_GET[LINKEDIN::_GET_RESPONSE] : '';
                if (!$_GET[LINKEDIN::_GET_RESPONSE]) {
                    // LinkedIn hasn't sent us a response, the user is initiating the connection
                    // send a request for a LinkedIn access token
                    $response = $OBJ_linkedin->retrieveTokenRequest();
                    //echo 'response: '.'<pre>'.print_r($response, true).'</pre>';
                    if ($response['success'] === TRUE) {
                        // store the request token
                        $session_oauth = $session->get('oauth');
                        $session_oauth['oauth']['linkedin']['request'] = $response['linkedin'];
                        $session->set('oauth', $session_oauth);
                        //redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
                        $app->redirect(LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
                    } else {
                        $profile_assoc = array();
                        $profile_assoc['response'] = false;
                        $profile_assoc['msg'] = "Request token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>";
                        return $profile_assoc;
                        // bad token request
                    }
                } else {
                    // LinkedIn has sent a response
                    // user has cancelled LinkedIn authentication
                    if (JRequest::getString('oauth_problem') == 'user_refused') {
                        $app->redirect('index.php?option=com_jobboard&view=user&task=addcv', JText::_('COM_JOBBOARD_IMPORTLINKEDINCANCELLED'));
                    }
                    // user has granted permission, take the temp access token, the user's secret and the verifier to request the user's real secret key
                    $session_oauth = $session->get('oauth');
                    $response = $OBJ_linkedin->retrieveTokenAccess($session_oauth['oauth']['linkedin']['request']['oauth_token'], $session_oauth['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']);
                    if ($response['success'] === TRUE) {
                        // the request went through without an error, gather user's 'access' tokens
                        $session_oauth['oauth']['linkedin']['access'] = $response['linkedin'];
                        // set the user as authorized for future quick reference
                        $session_oauth['oauth']['linkedin']['authorized'] = TRUE;
                        $session->set('oauth', $session_oauth);
                    } else {
                        // bad token access
                        echo "Access token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
                    }
                }
                $response = $OBJ_linkedin->profile('~:(id,first-name,last-name,summary,educations,positions,skills)');
                if ($response['success'] === TRUE) {
                    $profile = new SimpleXMLElement($response['linkedin']);
                    $profile_json = json_encode($profile);
                    $profile_assoc = array_unique(json_decode($profile_json, TRUE), SORT_REGULAR);
                    $profile_assoc['response'] = $response['success'];
                } else {
                    // profile retrieval failed
                    $profile_assoc = array();
                    $profile_assoc['response'] = false;
                }
                return $profile_assoc;
                break;
            case 'revoke':
                /**
                 * Handle authorization revocation.
                 */
                $session_oauth = $session->get('oauth');
                $OBJ_linkedin = new LinkedIn($API_CONFIG);
                $OBJ_linkedin->setTokenAccess($session_oauth['oauth']['linkedin']['access']);
                $response = $OBJ_linkedin->revoke();
                if ($response['success'] === TRUE) {
                    // revocation successful, clear session
                    if ($session->clear('oauth')) {
                        // session destroyed
                        //header('Location: ' . $_SERVER['PHP_SELF']);
                    } else {
                        // session not destroyed
                        echo "Error clearing user's session";
                    }
                } else {
                    // revocation failed
                    echo "Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
                }
                break;
            default:
                // nothing being passed back, display demo page
                // check PHP version
                if (version_compare(PHP_VERSION, '5.0.0', '<')) {
                    throw new LinkedInException('You must be running version 5.x or greater of PHP to use this library.');
                }
                // check for cURL
                if (extension_loaded('curl')) {
                    $curl_version = curl_version();
                    $curl_version = $curl_version['version'];
                } else {
                    throw new LinkedInException('You must load the cURL extension to use this library.');
                }
                $session_oauth = $session->get('oauth');
                if (!isset($session_oauth['oauth']['linkedin']['authorized'])) {
                    $session_oauth['oauth']['linkedin']['authorized'] = FALSE;
                    $session->set('oauth', $session_oauth);
                }
                if ($session_oauth['oauth']['linkedin']['authorized'] === TRUE) {
                    // user is already connected
                    $OBJ_linkedin = new LinkedIn($API_CONFIG);
                    $OBJ_linkedin->setTokenAccess($session_oauth['oauth']['linkedin']['access']);
                    ?>

                  <?php 
                    //$response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url)');
                    $response = $OBJ_linkedin->profile('~:(id,first-name,last-name,summary,educations,positions,skills)');
                    if ($response['success'] === TRUE) {
                        //$response['linkedin'] = new SimpleXMLElement($response['linkedin']);
                        // echo "<pre>" . print_r($response['linkedin'], TRUE) . "</pre>";
                        $profile = new SimpleXMLElement($response['linkedin']);
                        $profile_json = json_encode($profile);
                        return json_decode($profile_json, TRUE);
                    } else {
                        // profile retrieval failed
                        echo "Error retrieving profile information:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>";
                    }
                } else {
                    // user isn't connected
                    ?>
                  <?php 
                }
                ?>
            <?php 
                break;
        }
    }
Ejemplo n.º 7
0
/**
* Revoke Authorization.
*/
function bb_li_revoke()
{
    $API_CONFIG = array('appKey' => bb_get_option('li_app_id'), 'appSecret' => bb_get_option('li_secret'), 'callbackUrl' => NULL);
    // check the session
    try {
        $_SESSION['oauth']['linkedin']['authorized'] = isset($_SESSION['oauth']['linkedin']['authorized']) ? $_SESSION['oauth']['linkedin']['authorized'] : FALSE;
        if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
            $OBJ_linkedin = new LinkedIn($API_CONFIG);
            $OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
            $response = $OBJ_linkedin->revoke();
            //bb_die($response['info']['http_code']);
            if ($response['success'] == TRUE || $response['info']['http_code'] == 200) {
                // revocation successful, logout and clear session
                $var = 'oauth';
                unset($_SESSION[$var]);
                session_unregister($var);
                //bb_die(bb_get_option('uri'));
                //bb_safe_redirect(bb_get_option('uri').'bb-login.php?logout=1');
                $redirect_url = $_REQUEST['li_bb_revoke'];
                if (strpos($redirect_url, bb_get_option('uri')) !== 0) {
                    $redirect_url = bb_get_option('uri');
                }
                bb_safe_redirect($redirect_url);
                exit;
            } else {
                // revocation failed
                bb_die("revocation failed");
            }
        }
    } catch (LinkedInException $e) {
        error_log($e);
    }
}
Ejemplo n.º 8
0
             // Dårlig token adgang
             echo "Access token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($SimpleLI, TRUE) . "</pre>";
         }
     }
     break;
 case 'revoke':
     /**
      * Håndtere tilladelse tilbagekaldelse.
      */
     // Tjekker sessionen
     if (!oauth_session_exists()) {
         throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
     }
     $SimpleLI = new LinkedIn($API_CONFIG);
     $SimpleLI->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
     $response = $SimpleLI->revoke();
     if ($response['success'] === TRUE) {
         // Tilbagekaldelse lykkes, Ryd session
         session_unset();
         $_SESSION = array();
         if (session_destroy()) {
             // Session ødelagt
             header('Location: ' . $_SERVER['PHP_SELF']);
         } else {
             // Sessionen er ikke ødelagt
             echo "Error clearing user's session";
         }
     } else {
         // Tilbagekaldelse mislykkedes
         echo "Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($SimpleLI, TRUE) . "</pre>";
     }
Ejemplo n.º 9
0
require_once "class/frontend.class.php";
$front = Frontend::getInstance();
include_once "db_connect.php";
include_once "autoload.php";
require_once 'oauth/linkedin.class.php';
if (!$front->isUserLoggedIn()) {
    $front->getUser()->askUserToAuthenticate();
}
$messages = array();
$redirect = false;
if (isset($_POST['action'])) {
    if ($_POST['action'] == "revoke") {
        $API_CONFIG = array('appKey' => LINKEDIN_API_KEY_PUBLIC, 'appSecret' => LINKEDIN_API_KEY_PRIVATE, 'callbackUrl' => NULL);
        $OBJ_linkedin = new LinkedIn($API_CONFIG);
        $OBJ_linkedin->setTokenAccess(array('oauth_token' => $front->getUser()->getAccess_token(), 'oauth_token_secret' => $front->getUser()->getAccess_token_secret()));
        $OBJ_linkedin->revoke();
        $front->getUser()->deleteTokens();
    }
}
if (isset($_POST['nickname'])) {
    $nickname = trim($_POST['nickname']);
    $updateNickname = false;
    $updatePassword = false;
    if ($nickname != $_SESSION['nickname']) {
        if (strpos($nickname, ' ') !== false) {
            $front->getError()->setError("Your nickname cannot contain any spaces. Please try again.");
        } elseif (strlen($nickname) > MAX_NICKNAME_CHARS) {
            $front->getError()->setError("Your nickname must be less than " . MAX_NICKNAME_CHARS . " long.");
        } elseif (preg_match("/<(.|\n)*?>/", $nickname)) {
            $front->getError()->setError("Your nickname contained illegal characters. Please try again.");
        } else {