本文整理汇总了PHP中LinkedIn::retrieveTokenRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP LinkedIn::retrieveTokenRequest方法的具体用法?PHP LinkedIn::retrieveTokenRequest怎么用?PHP LinkedIn::retrieveTokenRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedIn
的用法示例。
在下文中一共展示了LinkedIn::retrieveTokenRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
function getData()
{
$session = JFactory::getSession();
$post = JRequest::get('post');
$redsocialhelper = new redsocialhelper();
$login = $redsocialhelper->getsettings();
if (!isset($post['generatetoken'])) {
return JText::_('PLEASE_SELECT_SECTION');
}
switch ($post['generatetoken']) {
case 'facebook':
$fb_profile_id = $session->set('fb_profile_id', $post['fb_profile_id']);
$app_id = $login['app_id'];
$app_secret = $login['app_secret'];
require_once JPATH_SITE . '/components/com_redsocialstream/helpers/facebook/facebook.php';
$redirect_url = urlencode(JURI::base() . "index.php?option=com_redsocialstream&view=access_token");
header("location: https://www.facebook.com/dialog/oauth?client_id=" . $login['app_id'] . "&redirect_uri=" . $redirect_url . "&scope=manage_pages,publish_stream&manage_pages=1&publish_stream=1");
break;
case 'linkedin':
//Linkedin APi Key
$api_key = $login['linked_api_key'];
//Linkedin Secret Key
$secret_key = $login['linked_secret_key'];
$redirect_url = JURI::base() . "index.php?option=com_redsocialstream&view=access_token";
$linkedin_profile_id = $session->set('linkedin_profile_id', $post['linkedin_profile_id']);
$API_CONFIG = array('appKey' => $api_key, 'appSecret' => $secret_key, 'callbackUrl' => $redirect_url);
$linkedin = new LinkedIn($API_CONFIG);
$response = $linkedin->retrieveTokenRequest();
if ($response['success'] === TRUE) {
$session->set('oauthReqToken', $response['linkedin']);
// redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
exit;
}
break;
}
}
示例2: loginBegin
/**
* {@inheritdoc}
*/
function loginBegin()
{
// send a request for a LinkedIn access token
$response = $this->api->retrieveTokenRequest();
if (isset($response['success']) && $response['success'] === true) {
$this->token("oauth_token", $response['linkedin']['oauth_token']);
$this->token("oauth_token_secret", $response['linkedin']['oauth_token_secret']);
# redirect user to LinkedIn authorisation web page
Hybrid_Auth::redirect(LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
} else {
throw new Exception("Authentication failed! {$this->providerId} returned an invalid Token.", 5);
}
}
示例3: try_li_connect
function try_li_connect()
{
global $_SESSION;
// start the session
if (!session_id()) {
bb_die('This script requires session support, which appears to be disabled according to session_start().');
}
// check for cURL
if (extension_loaded('curl')) {
$curl_version = curl_version();
$curl_version = $curl_version['version'];
} else {
bb_die('You must load the cURL extension to use this library.');
}
$API_CONFIG = array('appKey' => bb_get_option('li_app_id'), 'appSecret' => bb_get_option('li_secret'), 'callbackUrl' => NULL);
$API_CONFIG['callbackUrl'] = 'http://' . $_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);
try {
// perform linkedin rest authorization
$_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'];
// redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
exit;
} else {
// bad token request
bb_die("unable to connect to LinkedIn");
}
} else {
// 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($_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
$_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
// set the user as authorized for future quick reference
$_SESSION['oauth']['linkedin']['authorized'] = TRUE;
//bb_die($_SESSION['oauth']['linkedin']['request']['oauth_token']
//.' '.$_SESSION['oauth']['linkedin']['request']['oauth_token_secret']
//.' '.$_GET['oauth_verifier']);
} else {
// bad token access
bb_die("authorization failed");
}
}
} catch (LinkedInException $e) {
error_log($e);
}
return;
}
示例4: _startLinkedinHandshake
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;
}
}
示例5: __construct
public function __construct()
{
session_start();
// Create a LinkedIn object
$linkedInApiConfig = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => APP_URL . '/' . Content::l() . '/login/linkedincallback/' . (!empty($_GET['nextPage']) ? $_GET['nextPage'] : ''));
$linkedIn = new LinkedIn($linkedInApiConfig);
// Send a request for a LinkedIn access token
$response = $linkedIn->retrieveTokenRequest();
if ($response['success'] === TRUE) {
// Split up the response and stick the LinkedIn portion in the user session
$_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];
// Redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
header('Location: ' . LINKEDIN::_URL_AUTH . $_SESSION['oauth']['linkedin']['request']['oauth_token']);
} else {
$this->exitWithMessage('Unable to retrieve access token for LinkedIn');
}
}
示例6: LinkedIn
*/
// check for the correct http protocol (i.e. is this script being served via http or https)
if ($_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) {
// check the session
if (!oauth_session_exists()) {
throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
}
// split up the response and stick the LinkedIn portion in the user session
$_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];
// redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
header('Location: ' . LINKEDIN::_URL_AUTH . $_SESSION['oauth']['linkedin']['request']['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 {
// 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
示例7: index
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);
//.........这里部分代码省略.........
示例8: linkedin
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');
}
示例9: actionLinkedIn
public function actionLinkedIn()
{
try {
// start the session if not already started
if (!isset($_SESSION)) {
if (!session_start()) {
throw new LinkedInException('This script requires session support, which appears to be disabled according to session_start().');
}
}
require_once Yii::app()->basepath . '/extensions/linkedin/linkedin_3.2.0.class.php';
// display constants
$API_CONFIG = array('appKey' => Yii::app()->params['linkedinapikey'], 'appSecret' => Yii::app()->params['linkedinsecretkey'], 'callbackUrl' => '');
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] : '';
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$protocol = 'https';
} else {
$protocol = 'http';
}
// set and oauth session variable for future storage if it does not exist
$_SESSION['oauth']['linkedin']['authorized'] = isset($_SESSION['oauth']['linkedin']['authorized']) ? $_SESSION['oauth']['linkedin']['authorized'] : FALSE;
// 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';
//echo $API_CONFIG['callbackUrl'];
//$sitepath = "http://localhost";
$sitepath = "http://" . $_SERVER['SERVER_NAME'];
$url = $sitepath . Yii::app()->createUrl('login/linkedin', array(LINKEDIN::_GET_RESPONSE => '1'));
//$url = $sitepath . Yii::app()->createUrl('login/linkedin') ;
$API_CONFIG['callbackUrl'] = $url;
$OBJ_linkedin = new LinkedIn($API_CONFIG);
// check for responseh 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();
//print_r($response);
if ($response['success'] === TRUE) {
// check the session
if (!$this->oauth_session_exists()) {
throw new LinkedInException('oauth session is not yet set.');
}
// split up the response and stick the LinkedIn portion in the user session
$_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];
// redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
header('Location: ' . LINKEDIN::_URL_AUTH . $_SESSION['oauth']['linkedin']['request']['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 {
if (isset($_POST['Member']['memberid'])) {
$memberdata = Member::model()->getMemberById($_POST['Member']['memberid']);
$this->actMemberinfo($memberdata, '', '', '', 'linkedin', '');
} else {
// 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($_GET['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
$_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
// set the user as authorized for future quick reference
$_SESSION['oauth']['linkedin']['authorized'] = TRUE;
//$OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_JSON);
$response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url,email-address)');
//$response = $OBJ_linkedin->profile();
if ($response['success'] === TRUE) {
//echo "<pre>" . print_r($response['linkedin'], TRUE) . "</pre>";
// var_dump($response);
$linkedindata = $this->parseLinkedinResponse($response['linkedin']);
if (!empty($linkedindata)) {
//var_dump ($linkedindata);
//print strval($linkedindata->{"first-name"});
$memberdata = Member::model()->getMemberByOauth(strval($linkedindata->id));
$this->actMemberinfo($memberdata, '', '', $linkedindata, 'linkedin', '');
} else {
//For testing purposes, if there was an error, let's kill the script
die("There was an error.");
}
} else {
// profile retrieval failed
echo "Error retrieving profile information:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>";
}
// redirect the user back to the demo page
//header('Location: ' . $_SERVER['PHP_SELF']);
} 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>";
}
}
}
} catch (LinkedInException $e) {
// exception raised by library call
echo $e->getMessage();
}
}
示例10: linkedin
/**
*
*
* @return array
*/
function linkedin()
{
App::import("Vendor", "Users.linkedin/linkedin_3.2.0.class");
$response = array();
$user_profile = array();
$ldnToken = '';
$ldnSecret = '';
$API_CONFIG = array('appKey' => LINKEDIN_API_KEY, 'appSecret' => LINKEDIN_SECRET_KEY, 'callbackUrl' => NULL);
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$protocol = 'https';
} else {
$protocol = 'http';
}
$API_CONFIG['callbackUrl'] = Router::url(array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'linkedin'), true) . '?' . 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'];
// redirect the user to the LinkedIn authentication/authorisation page to initiate validation.
$response['url'] = LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token'];
} else {
// bad token request
$response['Request_Token_Failed_Response'] = $response;
$response['Request_Token_Failed_Linkedin'] = $OBJ_linkedin;
}
} else {
// 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($_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
$_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
// set the user as authorized for future quick reference
$_SESSION['oauth']['linkedin']['authorized'] = TRUE;
// redirect the user back to the demo page
//header('Location: ' . $_SERVER['PHP_SELF']);
$response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url)');
if ($response['success'] === TRUE) {
$user_profile = new SimpleXMLElement($response['linkedin']);
$ldnSecret = $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'];
$ldnToken = $_SESSION['oauth']['linkedin']['request']['oauth_token'];
} else {
// request failed
$user_profile = '';
$ldnSecret = $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'];
$ldnToken = $_SESSION['oauth']['linkedin']['request']['oauth_token'];
}
} else {
// bad token access
$response['Request_Token_Failed_Response'] = $response;
$response['Request_Token_Failed_Linkedin'] = $OBJ_linkedin;
}
}
$response['user_profile'] = $user_profile;
return $response;
}
示例11: linkedInButtonAction
/**
* this function used to authentication/authorisation from the user to the applecation
* @author Ahmed <a.ibrahim@objects.ws>
* @param string $callbackUrl
*/
public function linkedInButtonAction($callbackUrl, $popup)
{
//linkedIn config parameters
$config = array('appKey' => $this->container->getParameter('linkedin_api_key'), 'appSecret' => $this->container->getParameter('linkedin_secret_key'), 'callbackUrl' => $this->generateUrl('linkedInCallBack', array(), TRUE));
//create new linkedIn oauth object
$oauth = new \LinkedIn($config);
//get request token
$request_token = @$oauth->retrieveTokenRequest();
$session = $this->getRequest()->getSession();
$session->set('oauth_token', $request_token['linkedin']['oauth_token']);
$session->set('oauth_token_secret', $request_token['linkedin']['oauth_token_secret']);
$session->set('callbackUrl', $callbackUrl);
//check if we will set the popup flag
if ($popup == 'yes') {
//set the flag
$session->set('linkedInPopup', TRUE);
}
// redirect the user to the LinkedIn authentication/authorisation page.
$url = \LINKEDIN::_URL_AUTH . $request_token['linkedin']['oauth_token'];
return $this->redirect($url);
}
示例12: display
/**
* Method to setup linkedin params and redirect to linkedin auth URL
*
* @access public
* @param object $view view object
* @param object $tpl template object
* @return void
*/
public function display($view, $tpl)
{
// Set up the redirect URL
$return = isset($view->return) ? '&return=' . $view->return : '';
$redirect_to = self::getRedirectUri('linkedin') . $return;
// User initiated LinkedIn connection, setup linkedin configuration
$config = array('callbackUrl' => $redirect_to . '&' . LINKEDIN::_GET_TYPE . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1', 'appKey' => $this->params->get('api_key'), 'appSecret' => $this->params->get('app_secret'));
// Create linkedin object
$client = new LinkedIn($config);
// Check for a 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
$reply = $client->retrieveTokenRequest();
if ($reply['success'] === TRUE) {
// Store the request token
App::get('session')->set('linkedin.oauth.request', $reply['linkedin']);
// Redirect the user to the LinkedIn authentication/authorization page to initiate validation
App::redirect(LINKEDIN::_URL_AUTH . $reply['linkedin']['oauth_token']);
}
return;
}
// Are the already logged on?
return new Exception(Lang::txt('PLG_AUTHENTICATION_LINKEDIN_ERROR'), 500);
}
示例13: getLinkedinProfile
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
//.........这里部分代码省略.........
示例14: test
function test($ltype = '', $response = '', $oauth_token = '', $oauth_verfier = '')
{
$this->data['success'] = FALSE;
function oauth_session_exists()
{
if (is_array($_SESSION) && array_key_exists('oauth', $_SESSION)) {
return TRUE;
} else {
return FALSE;
}
}
try {
// include the LinkedIn class
//require_once('linkedin_3.2.0.class.php');
// start the session
// if(!session_start()) {
// throw new LinkedInException('This script requires session support, which appears to be disabled according to session_start().');
// }
// display constants
if (isset($_REQUEST['invitation_key'])) {
$this->data['invitation_key_val'] = $_REQUEST['invitation_key'];
} elseif ($this->input->post('invitation_key')) {
$this->data['invitation_key_val'] = $this->input->post('invitation_key');
} else {
$this->data['invitation_key_val'] = '';
}
if (isset($_REQUEST['email_val'])) {
$this->data['email_val'] = $_REQUEST['email_val'];
} elseif ($this->input->post('email_val')) {
$this->data['email_val'] = $this->input->post('email_val');
} else {
$this->data['email_val'] = '';
}
$API_CONFIG = array('appKey' => 'ctfw9ywn6vrm', 'appSecret' => 'T2G5ccnIfGytPAdt', 'callbackUrl' => NULL);
define('DEMO_GROUP', '4010474');
define('DEMO_GROUP_NAME', 'Simple LI Demo');
define('PORT_HTTP', '80');
define('PORT_HTTP_SSL', '443');
// set index
//echo "<script type='text/javascript'>console.log('@".LINKEDIN::_GET_TYPE."".print_r($this->uri)."')</script>";
$_REQUEST[LINKEDIN::_GET_TYPE] = isset($_REQUEST[LINKEDIN::_GET_TYPE]) ? $_REQUEST[LINKEDIN::_GET_TYPE] : '';
//echo "<script type='text/javascript'>console.log('@".$_REQUEST[LINKEDIN::_GET_TYPE]."')</script>";
switch ($_REQUEST[LINKEDIN::_GET_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']) && $_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'];
// 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 {
// 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($_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
$_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
$this->data['success'] = TRUE;
$this->data['status'] = TRUE;
$response['linkedin'] = new SimpleXMLElement($response['linkedin']);
// set the user as authorized for future quick reference
$_SESSION['oauth']['linkedin']['authorized'] = TRUE;
// redirect the user back to the demo page
header('Location: ' . $_SERVER['PHP_SELF']);
} 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>";
}
}
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'];
//.........这里部分代码省略.........
示例15: pullLinkedInData
private function pullLinkedInData()
{
/**
* Helper function that checks to see that we have a 'set' $_SESSION that we can
* use for the demo.
*/
function oauth_session_exists()
{
if (is_array($_SESSION) && array_key_exists('oauth', $_SESSION)) {
return TRUE;
} else {
return FALSE;
}
}
try {
session_start();
// display constants
$API_CONFIG = array('appKey' => $this->config->item('linkedin_appKey', 'linkedin_oauth'), 'appSecret' => $this->config->item('linkedin_appSecret', 'linkedin_oauth'), '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 ($_REQUEST[LINKEDIN::_GET_TYPE]) {
case 'initiate':
// check for the correct http protocol (i.e. is this script being served via http or https)
if (!empty($_SERVER['HTTPS'])) {
$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'];
// 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 {
// 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($_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
$_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
// set the user as authorized for future quick reference
$_SESSION['oauth']['linkedin']['authorized'] = TRUE;
// pulling everything in LinkedIn
$fields = "id," . "first-name," . "last-name," . "headline," . "location," . "industry," . "distance," . "relation-to-viewer," . "current-share," . "connections," . "num-connections," . "num-connections-capped," . "summary," . "specialties," . "proposal-comments," . "associations," . "honors," . "interests," . "positions," . "publications," . "patents," . "languages," . "skills," . "certifications," . "educations," . "three-current-positions," . "three-past-positions," . "num-recommenders," . "recommendations-received," . "phone-numbers," . "im-accounts," . "twitter-accounts," . "date-of-birth," . "main-address," . "member-url-resources," . "picture-url," . "site-standard-profile-request," . "api-public-profile-request," . "site-public-profile-request," . "api-standard-profile-request," . "public-profile-url";
$info = $OBJ_linkedin->profile('~:(' . $fields . ')');
if ($info['success'] === TRUE) {
// store user's data in database
$info['linkedin'] = new SimpleXMLElement($info['linkedin']);
$linkedin_data = $info['linkedin']->asXML();
//Logger::log($linkedin_data);
if ($this->linkedin_model->insertLinkedInDataForCurrentUser($linkedin_data)) {
//echo 'Your profile has been synchronized with Linkedin! Redirecting...';
redirect('user/profile', 'refresh');
} else {
echo 'Error occurred! Please try again later.';
}
} else {
// profile retrieval failed
echo "Error retrieving profile information:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($info) . "</pre>";
}
} 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>";
}
}
break;
default:
// [BH] BAD CODING!
// SHOULDN'T ECHO ANYTHING IN CONTROLLERS.
//echo 'Error: No page found!';
break;
}
} catch (LinkedInException $e) {
// exception raised by library call
echo $e->getMessage();
}
}