當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LinkedIn::getProfile方法代碼示例

本文整理匯總了PHP中LinkedIn::getProfile方法的典型用法代碼示例。如果您正苦於以下問題:PHP LinkedIn::getProfile方法的具體用法?PHP LinkedIn::getProfile怎麽用?PHP LinkedIn::getProfile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LinkedIn的用法示例。


在下文中一共展示了LinkedIn::getProfile方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: demo

 public function demo()
 {
     session_start();
     $this->load->helper('url');
     $this->load->library('linkedin');
     $config['base_url'] = base_url('home/linkedin');
     $config['callback_url'] = base_url('home/demo');
     $config['linkedin_access'] = '75cmijp7gpecgv';
     $config['linkedin_secret'] = 'CkLc98T2vkqc4vEh';
     # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
     $linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']);
     //$linkedin->debug = true;
     if (isset($_REQUEST['oauth_verifier'])) {
         $_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
         $linkedin->request_token = unserialize($_SESSION['requestToken']);
         $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
         $linkedin->getAccessToken($_REQUEST['oauth_verifier']);
         $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
         header("Location: " . $config['callback_url']);
         exit;
     } else {
         $linkedin->request_token = unserialize($_SESSION['requestToken']);
         $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
         $linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
     }
     # You now have a $linkedin->access_token and can make calls on behalf of the current member
     $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,email-address,headline,picture-url)");
     /* echo '<pre>';
        echo 'My Profile Info';
        echo $xml_response;
        echo '<br />';
        echo '</pre>';*/
     $id = $linkedin->getProfile('~:(id)');
     $email = $linkedin->getProfile('~:(email-address)');
     $uid = trim(strip_tags($id));
     $email_address = trim(strip_tags($email));
     $response = $this->home->linkedinauth($email_address);
     if ($response == 1) {
         $this->home->set_online_status(1);
         if ($this->session->userdata('is_login')) {
             if ($this->session->userdata('is_alumni')) {
                 redirect(base_url('alumni'));
             } elseif ($this->session->userdata('is_prospective')) {
                 redirect(base_url('parents'));
             } else {
                 redirect(base_url('seeker'));
             }
         }
     } else {
         redirect(base_url('home'));
     }
     $this->data['view_file'] = 'index';
     echo Modules::run('template/home', $this->data);
 }
開發者ID:Entellus,項目名稱:red,代碼行數:54,代碼來源:home_18.php

示例2: onSloginCheck

 public function onSloginCheck()
 {
     $redirect = JURI::base() . '?option=com_slogin&task=check&plugin=linkedin';
     $app = JFactory::getApplication();
     $input = $app->input;
     $oauth_problem = $input->getString('oauth_problem', '');
     if ($oauth_problem == 'user_refused') {
         $config = JComponentHelper::getParams('com_slogin');
         JModel::addIncludePath(JPATH_ROOT . '/components/com_slogin/models');
         $model = JModel::getInstance('Linking_user', 'SloginModel');
         $redirect = base64_decode($model->getReturnURL($config, 'failure_redirect'));
         $controller = JControllerLegacy::getInstance('SLogin');
         $controller->displayRedirect($redirect, true);
     }
     # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
     $linkedin = new LinkedIn($this->params->get('api_key'), $this->params->get('secret_key'), $redirect);
     //$linkedin->debug = true;
     $oauth_verifier = $input->getString('oauth_verifier', '');
     $requestToken = unserialize($app->getUserState('requestToken'));
     $linkedin->request_token = $requestToken;
     $linkedin->oauth_verifier = $app->getUserState('oauth_verifier');
     if (!empty($oauth_verifier)) {
         $app->setUserState('oauth_verifier', $oauth_verifier);
         $linkedin->getAccessToken($oauth_verifier);
         $app->setUserState('oauth_access_token', serialize($linkedin->access_token));
         header("Location: " . $redirect);
         exit;
     } else {
         $linkedin->access_token = unserialize($app->getUserState('oauth_access_token'));
     }
     # You now have a $linkedin->access_token and can make calls on behalf of the current member
     //$request = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url)");
     $request = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,email-address)?format=json");
     $request = json_decode($request);
     if (empty($request)) {
         echo 'Error - empty user data';
         exit;
     } else {
         if (!empty($request->errorCode)) {
             echo 'Error - ' . $request->message;
             exit;
         }
     }
     $returnRequest = new SloginRequest();
     $returnRequest->first_name = $request->firstName;
     $returnRequest->last_name = $request->lastName;
     //            $returnRequest->email       = $request->email;
     $returnRequest->id = $request->id;
     $returnRequest->real_name = $request->firstName . ' ' . $request->lastName;
     $returnRequest->display_name = $request->firstName;
     $returnRequest->all_request = $request;
     return $returnRequest;
 }
開發者ID:gaetanodanelli,項目名稱:slogin,代碼行數:53,代碼來源:linkedin.php

示例3: linkedinGetLoggedinUserInfo

 public function linkedinGetLoggedinUserInfo($requestToken = '', $oauthVerifier = '', $accessToken = '')
 {
     include_once $this->config['linkedin_library_path'];
     $linkedin = new LinkedIn($this->config['linkedin_access'], $this->config['linkedin_secret']);
     $linkedin->request_token = unserialize($requestToken);
     //as data is passed here serialized form
     $linkedin->oauth_verifier = $oauthVerifier;
     $linkedin->access_token = unserialize($accessToken);
     try {
         $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,public-profile-url)");
     } catch (Exception $o) {
         print_r($o);
     }
     return $xml_response;
 }
開發者ID:BGCX067,項目名稱:facebook-twitter-linkedin-status-update-svn-to-git,代碼行數:15,代碼來源:class.fblinkedtwit.php

示例4: linkedinGetUserInfo

 public function linkedinGetUserInfo($requestToken = '', $oauthVerifier = '', $accessToken = '')
 {
     include_once 'linkedinoAuth.php';
     $linkedin = new LinkedIn($this->config['linkedin_access'], $this->config['linkedin_secret']);
     $linkedin->request_token = unserialize($requestToken);
     //as data is passed here serialized form
     $linkedin->oauth_verifier = $oauthVerifier;
     $linkedin->access_token = unserialize($accessToken);
     try {
         $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,interests,publications,patents,languages,skills,date-of-birth,email-address,phone-numbers,im-accounts,main-address,twitter-accounts,headline,picture-url,public-profile-url)");
     } catch (Exception $o) {
         print_r($o);
     }
     return $xml_response;
 }
開發者ID:neevan1e,項目名稱:Done,代碼行數:15,代碼來源:class.linkedClass.php

示例5: linkedin_login

 public function linkedin_login()
 {
     $config['base_url'] = base_url('auth/get_linkedin_url');
     $config['callback_url'] = base_url('auth/linkedin_login');
     $config['linkedin_access'] = '78iwuorjnrw04c';
     $config['linkedin_secret'] = 'J05AYZ236vVmIc3e';
     $linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']);
     if (isset($_REQUEST['oauth_verifier'])) {
         $_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
         $linkedin->request_token = unserialize($_SESSION['requestToken']);
         $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
         $linkedin->getAccessToken($_REQUEST['oauth_verifier']);
         $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
         $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url)");
         die($linkedin->getAccessToken($_REQUEST['oauth_verifier']));
         $user_data = explode(' ', $xml_response);
         $data = array('id' => $user_data[5], 'first_name' => $user_data[7], 'last_name' => $user_data[9], 'email' => $user_data[5], 'isLogged' => TRUE, 'role' => 0);
         $this->session->set_userdata($data);
         $linkedin_users = $this->users_model->get_record_by_filed(array('email' => $user_data[5]));
         if (count($linkedin_users) == 0) {
             $last_id = $this->users_model->insert_data($data);
         } else {
             $last_id = $this->users_model->get_record(array('email' => $user_data[5]));
             $this->users_model->update_record($last_id->id, $data);
         }
         redirect('frontend/home');
     } else {
         redirect('auth/index');
     }
 }
開發者ID:jelek92,項目名稱:Store,代碼行數:30,代碼來源:Auth.php

示例6: unserialize

//$linkedin->debug = true;
if (isset($_REQUEST['oauth_verifier'])) {
    $_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
    $linkedin->request_token = unserialize($_SESSION['requestToken']);
    $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
    $linkedin->getAccessToken($_REQUEST['oauth_verifier']);
    $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
    header("Location: " . $config['callback_url']);
    exit;
} else {
    $linkedin->request_token = unserialize($_SESSION['requestToken']);
    $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
    $linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
}
# You now have a $linkedin->access_token and can make calls on behalf of the current member
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline)");
$xml_response1 = $linkedin->getProfile("~:(picture-url)");
//echo '<pre>';
//echo 'My Profile Info';
//echo $xml_response;
$pic = simplexml_load_string($xml_response1);
// or die("Error: Cannot create object");
//print_r($pic);
$profile = simplexml_load_string($xml_response);
//print_r($profile);
$a = (string) $profile->id;
$b = (string) $profile->{'first-name'};
$c = (string) $profile->{'last-name'};
$d = (string) $profile->headline;
$url = (string) $pic->{'picture-url'};
?>
開發者ID:nilmadhab,項目名稱:linkdin,代碼行數:31,代碼來源:demo.php

示例7: serialize

        $linkedin->getAccessToken($_REQUEST['oauth_verifier']);

        $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
        header("Location: " . $config['callback_url']);
        exit;
   }
   else{
        $linkedin->request_token    =   unserialize($_SESSION['requestToken']);
        $linkedin->oauth_verifier   =   $_SESSION['oauth_verifier'];
        $linkedin->access_token     =   unserialize($_SESSION['oauth_access_token']);
   }


    # You now have a $linkedin->access_token and can make calls on behalf of the current member
   
	$xml_response = $linkedin->getProfile("~:(id,headline,industry,positions)");
        $data = simplexml_load_string($xml_response);
        $data1=  json_encode($data);
        $update="UPDATE members SET linkedin_data = '".$data1."'  where id = '".$_SESSION['logged_user'][0]['id']."'";
	$db_updatepage=$obj->edit($update);	
        $_SESSION['linkedin_id']= 1;
        echo "<script>window.location='edit_profile.php'</script>";
   /* echo '<pre>';
    echo 'My Profile Info';
   
	$data = simplexml_load_string($xml_response1);
	print_r($data);
	$value=$data->{'positions'};
	
	echo $data->industry;
    echo $value->position->title;
開發者ID:OkyJ,項目名稱:findmyjodi,代碼行數:31,代碼來源:demo.php

示例8: actionRegisterLinkedIn

 public function actionRegisterLinkedIn()
 {
     // if user canceled, redirect to home page
     if (isset($_GET['oauth_problem'])) {
         $problem = $_GET['oauth_problem'];
         if ($problem == 'user_refused') {
             $this->redirect('/JobFair/index.php');
         }
     }
     if (!isset($_SESSION)) {
         session_start();
     }
     //edit by Manuel making the link dynamic, using Yii
     $config['base_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/auth1.php';
     $config['callback_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/RegisterLinkedIn';
     $config['linkedin_access'] = '2rtmn93gu2m4';
     $config['linkedin_secret'] = 'JV0fYG9ls3rclP8v';
     include_once Yii::app()->basePath . "/views/user/linkedin.php";
     # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
     $linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']);
     //$linkedin->debug = true;
     if (isset($_REQUEST['oauth_verifier'])) {
         $_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
         $linkedin->request_token = unserialize($_SESSION['requestToken']);
         $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
         $linkedin->getAccessToken($_REQUEST['oauth_verifier']);
         $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
         header("Location: " . $config['callback_url']);
         exit;
     } else {
         $linkedin->request_token = unserialize($_SESSION['requestToken']);
         $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
         $linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
     }
     # You now have a $linkedin->access_token and can make calls on behalf of the current member
     $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,industry,email-address,languages,phone-numbers,skills,educations,location:(name),positions,picture-urls::(original))");
     $data = simplexml_load_string($xml_response);
     // get user by linkedinid
     $model = new User();
     $user = User::model()->findByAttributes(array('linkedinid' => $data->id));
     // check if user exits in database, if so login
     if ($user != null) {
         if ($user->disable != 1) {
             $identity = new UserIdentity($user->username, '');
             if ($identity->authenticateOutside()) {
                 Yii::app()->user->login($identity);
             }
             $this->redirect("/JobFair/index.php/home/studenthome");
             return;
         } else {
             $this->redirect("/JobFair/index.php/site/page?view=disableUser");
             return;
         }
         // register
     } else {
         // 			print "<pre>"; print_r('user is null');print "</pre>";
         // check that there is no duplicate user if so link to that account
         $duplicateUser = User::model()->findByAttributes(array('email' => $data->{'email-address'}));
         if ($duplicateUser != null) {
             // get username and link the accounts
             $username = $duplicateUser->username;
             $user = User::model()->find("username=:username", array(':username' => $username));
             $user->linkedinid = $data->{'id'};
             $user->save(false);
             $user_id = $user->id;
             // ------------------BASIC INFO---------------
             $basic_info = null;
             $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $user_id));
             if ($basic_info == null) {
                 $basic_info = new BasicInfo();
             }
             $basic_info->userid = $user_id;
             $basic_info->save(false);
             // ------------------BASIC INFO -----------------
             // -----------------EDUCATION ----------------------
             // get number of educations to add
             $educ_count = $data->educations['total'];
             // delete current educations
             $delete_educs = Education::model()->findAllByAttributes(array('FK_user_id' => $user_id));
             foreach ($delete_educs as $de) {
                 $de->delete();
             }
             // add educations
             for ($i = 0; $i < $educ_count; $i++) {
                 // first check if current education is in school table. if not, add it
                 $current_school_name = $data->educations->education[$i]->{'school-name'};
                 $school_exists = School::model()->findByAttributes(array('name' => $current_school_name));
                 if ($school_exists == null) {
                     $new_school = new School();
                     $new_school->name = $current_school_name;
                     $new_school->save();
                     $school_id = School::model()->findByAttributes(array('name' => $current_school_name))->id;
                 } else {
                     $school_id = $school_exists->id;
                 }
                 // now ready to add new education
                 $new_educ = new Education();
                 $new_educ->degree = $data->educations->education[$i]->degree;
                 $new_educ->major = $data->educations->education[$i]->{'field-of-study'};
                 // 	   	$model->admission_date=date('Y-m-d',strtotime($model->admission_date));
//.........這裏部分代碼省略.........
開發者ID:erick305,項目名稱:testing,代碼行數:101,代碼來源:UserController.php

示例9: unserialize

 //print_r($_SESSION);
 if (isset($_REQUEST['oauth_verifier'])) {
     $_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
     $linkedin->request_token = unserialize($_SESSION['requestToken']);
     $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
     $linkedin->getAccessToken($_REQUEST['oauth_verifier']);
     $_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
     header("Location: " . $config['callback_url']);
     exit;
 } else {
     $linkedin->request_token = unserialize($_SESSION['requestToken']);
     $linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
     $linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
 }
 # You now have a $linkedin->access_token and can make calls on behalf of the current member
 $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,public-profile-url)");
 if ($xml_response) {
     $linkedinarr = getXMLtoArr($xml_response);
     if ($linkedinarr['id']) {
         /*
         echo '<pre>';
         echo 'My Profile Info';
         echo $xml_response;
         echo '<br />';
         print_r($linkedinarr);
         $json = json_encode($linkedinarr);
         echo $json; 
         $a = (json_decode($json));
         $a = objectToArray($a);
         echo $a['first-name'];
         */
開發者ID:juslee,項目名稱:e27,代碼行數:31,代碼來源:main.php


注:本文中的LinkedIn::getProfile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。