当前位置: 首页>>代码示例>>PHP>>正文


PHP LinkedIn::profile方法代码示例

本文整理汇总了PHP中LinkedIn::profile方法的典型用法代码示例。如果您正苦于以下问题:PHP LinkedIn::profile方法的具体用法?PHP LinkedIn::profile怎么用?PHP LinkedIn::profile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkedIn的用法示例。


在下文中一共展示了LinkedIn::profile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUserIdFromApi

 protected function getUserIdFromApi()
 {
     // 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);
     try {
         $response = $linkedIn->retrieveTokenAccess($_GET['oauth_token'], $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']);
     } catch (Error $e) {
         Debug::l('Error. Could not retrieve LinkedIn access token. ' . $e);
         header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
         exit;
     }
     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;
     } else {
         $this->exitWithMessage('Error. The OAuth access token was not retrieved. ' . print_r($response, 1));
     }
     $this->accessToken = serialize($response['linkedin']);
     /*
     Retrieve the user ID
     The XML response will look like one of these:
     
     <person>
       <id>8GhzNjjaOi</id>
     </person>
     
     <error>
       <status>401</status>
       <timestamp>1288518358054</timestamp>
       <error-code>0</error-code>
       <message>[unauthorized]. The token used in the OAuth request is not valid.</message>
     </error>
     */
     try {
         $response = $linkedIn->profile('~:(id,first-name,last-name)');
         if ($response['success'] === TRUE) {
             $response['linkedin'] = new SimpleXMLElement($response['linkedin']);
             if ($response['linkedin']->getName() != 'person') {
                 Debug::l('Error. Could not retrieve person data from LinkedIn. ' . print_r($response, 1));
                 header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
                 exit;
             }
         } else {
             Debug::l('Error. Could not retrieve person data from LinkedIn. ' . print_r($response, 1));
             header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
             exit;
         }
         $this->linkedInId = (string) $response['linkedin']->id;
         $this->name = $response['linkedin']->{'first-name'} . ' ' . $response['linkedin']->{'last-name'};
     } catch (Error $e) {
         Debug::l('Error. Could not retrieve person ID from LinkedIn. ' . $e);
         header('Location: ' . APP_URL . '/' . Content::l() . '/login/linkedin/');
         exit;
     }
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:58,代码来源:LoginLinkedInCallback.php

示例2: LinkedIn

 function get_resume_data()
 {
     $this->_check_auth();
     $API_CONFIG = $this->config->item('LINKEDIN_KEYS');
     $OBJ_linkedin = new LinkedIn($API_CONFIG);
     $OBJ_linkedin->setTokenAccess($this->session->userdata('access'));
     $OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_JSON);
     $resumeResponse = $OBJ_linkedin->profile('~:(first-name,last-name,formatted-name,industry,skills,summary,specialties,positions,picture-url,educations,interests,headline,phone-numbers,email-address,member-url-resources)');
     if ($resumeResponse['success'] === TRUE) {
         $resumeData = json_decode($resumeResponse['linkedin'], true);
         //print_r($resumeData);
         $this->load->model('resume');
         $userId = $this->session->userdata('user_id');
         $resumeData = array();
         $resumeData['user_id'] = $userId;
         $resumeData['json_data'] = $resumeResponse['linkedin'];
         $resumeData['update_date'] = date('Y-m-d h:i:s');
         if (!$this->resume->exist($userId)) {
             $resumeData['create_date'] = date('Y-m-d h:i:s');
             $resumeId = $this->resume->create($resumeData);
         } else {
             $resumeId = $this->resume->update_user_id($userId, $resumeData);
         }
         redirect('/builder/customize/' . $resumeId, 'refresh');
     }
 }
开发者ID:njhamann,项目名称:LInkedIn-Resume-Generator,代码行数:26,代码来源:builder.php

示例3: loadProfiles

 private function loadProfiles($person, $personIsUser)
 {
     $profiles = array();
     if (!empty($person['facebook_access_token']) && (!$personIsUser || $this->mergeNetwork != 'Facebook')) {
         try {
             //$params = array('access_token' => $user['facebook_access_token']);
             $facebookProfile = SessionManager::getInstance()->getFacebook()->api('/' . $person['facebook_id']);
         } catch (FacebookApiException $e) {
             Debug::l('Error loading Facebook profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
         }
         if (isset($facebookProfile)) {
             $profiles[] = '<a href="' . $facebookProfile['link'] . '" target="_blank" class="profile"><img src="https://graph.facebook.com/' . $person['facebook_id'] . '/picture?type=square" /> ' . $facebookProfile['name'] . ' on Facebook</a>';
         }
     }
     if (!empty($person['linkedin_access_token']) && (!$personIsUser || $this->mergeNetwork != 'LinkedIn')) {
         $API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => '');
         $OBJ_linkedin = new LinkedIn($API_CONFIG);
         $OBJ_linkedin->setTokenAccess(unserialize($person['linkedin_access_token']));
         try {
             $linkedInProfile = $OBJ_linkedin->profile('id=' . $person['linkedin_id'] . ':(first-name,last-name,public-profile-url,picture-url)');
         } catch (ErrorException $e) {
             Debug::l('Error loading LinkedIn profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
         }
         if ($linkedInProfile['success'] === TRUE) {
             $linkedInProfile['linkedin'] = new SimpleXMLElement($linkedInProfile['linkedin']);
             if ($linkedInProfile['linkedin']->getName() == 'person') {
                 $li_pr = (string) $linkedInProfile['linkedin']->{'public-profile-url'};
                 $li_pi = (string) $linkedInProfile['linkedin']->{'picture-url'};
                 $li_fn = (string) $linkedInProfile['linkedin']->{'first-name'};
                 $li_ln = (string) $linkedInProfile['linkedin']->{'last-name'};
                 $profiles[] = '<a href="' . $li_pr . '" target="_blank" class="profile"><img src="' . $li_pi . '" /> ' . $li_fn . ' ' . $li_ln . ' on LinkedIn</a>';
             }
         }
     }
     if (!empty($person['twitter_access_token']) && ($personIsUser || $this->mergeNetwork != 'Twitter')) {
         try {
             $twitterAccessToken = unserialize($person['twitter_access_token']);
             $twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $twitterAccessToken['oauth_token'], $twitterAccessToken['oauth_token_secret']);
             $twitter->format = 'json';
             $twitterProfile = $twitter->get('users/show', array('user_id' => $person['twitter_id']));
         } catch (ErrorException $e) {
             Debug::l('Error loading Twitter profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
         }
         if (isset($twitterProfile)) {
             $profiles[] = '<a href="http://twitter.com/' . $twitterProfile->screen_name . '" target="_blank" class="profile"><img src="' . $twitterProfile->profile_image_url . '" /> @' . $twitterProfile->screen_name . ' on Twitter</a>';
         }
     }
     return $profiles;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:49,代码来源:PageMergeAccounts.php

示例4: getUserData

 /**
  * this function used to get all linkedIn user data
  * @author Ahmed <a.ibrahim@objects.ws>
  * @param string $appKey
  * @param string $appSecret
  * @param array $linkedIn_oauth array of user oauth data
  */
 public static function getUserData($appKey, $appSecret, $linkedIn_oauth)
 {
     //linkedIn config parameters
     $config = array('appKey' => $appKey, 'appSecret' => $appSecret, 'callbackUrl' => '');
     //create new linkedIn oauth object
     $oauth = new \LinkedIn($config);
     $oauth->setTokenAccess($linkedIn_oauth);
     $userData = $oauth->profile('~:(id,first-name,last-name,picture-url,headline,site-standard-profile-request,location:(country:(code)),summary,positions,skills,educations,courses,email-address,phone-numbers,main-address,date-of-birth)');
     //check if connection success with twitter
     if (200 == $userData['info']['http_code']) {
         return $userData;
     } else {
         return NULL;
     }
 }
开发者ID:0bjects,项目名称:APIBundle,代码行数:22,代码来源:LinkedinController.php

示例5: getUserContacts

 /**
  * {@inheritdoc}
  */
 function getUserContacts()
 {
     try {
         $response = $this->api->profile('~/connections:(id,first-name,last-name,picture-url,public-profile-url,summary)');
     } catch (LinkedInException $e) {
         throw new Exception("User contacts request failed! {$this->providerId} returned an error: {$e}");
     }
     if (!$response || !$response['success']) {
         return array();
     }
     $connections = new SimpleXMLElement($response['linkedin']);
     $contacts = array();
     foreach ($connections->person as $connection) {
         $uc = new Hybrid_User_Contact();
         $uc->identifier = (string) $connection->id;
         $uc->displayName = (string) $connection->{'last-name'} . " " . $connection->{'first-name'};
         $uc->profileURL = (string) $connection->{'public-profile-url'};
         $uc->photoURL = (string) $connection->{'picture-url'};
         $uc->description = (string) $connection->{'summary'};
         $contacts[] = $uc;
     }
     return $contacts;
 }
开发者ID:nullziu,项目名称:hybridauth,代码行数:26,代码来源:LinkedIn.php

示例6: LinkedIn

      <div class="fill">
        <div class="container">
          <a class="brand" href="#">LinkedIn Assestment - Falcon Social</a>
        </div>
      </div>
    </div>
    <div class="container">
          <?php 
            if (checkSession() === true) {
                // Bruger er allerede tilsluttet
                $SimpleLI = new LinkedIn($API_CONFIG);
                $SimpleLI->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
                ?>
            
            <?php 
                $response = $SimpleLI->profile('~:(id,first-name,last-name,headline,industry,summary,location,picture-url,positions,educations,recommendations-received,connections)');
                if ($response['success'] === TRUE) {
                    $response['linkedin'] = new SimpleXMLElement($response['linkedin']);
                    $li_profile = $response['linkedin'];
                    ?>
          <div class="well">
            <img src="<?php 
                    echo $li_profile->{'picture-url'};
                    ?>
" style="float: left; padding-right: 10px;">
            <h1><?php 
                    echo $li_profile->{'first-name'} . ' ' . $li_profile->{'last-name'};
                    ?>
<br />
              <small><?php 
                    echo $li_profile->{'headline'};
开发者ID:Christophek,项目名称:Falcon_Social,代码行数:31,代码来源:index.php

示例7: linkedin

 function linkedin()
 {
     $cookie_name = "linkedin_oauth_" . SETTING::linkedInAPI;
     //Check if Cookie exists &&  Login is enabled
     if ($this->repository->get_data("linkedinLogin") && isset($_COOKIE[$cookie_name]) && $_COOKIE[$cookie_name]) {
         $credentials_json = $_COOKIE[$cookie_name];
         // where PHP stories cookies
         $credentials = json_decode($credentials_json);
         // validate signature
         if ($credentials->signature_version == 1) {
             if ($credentials->signature_order && is_array($credentials->signature_order)) {
                 $base_string = '';
                 // build base string from values ordered by signature_order
                 foreach ($credentials->signature_order as $key) {
                     if (isset($credentials->{$key})) {
                         $base_string .= $credentials->{$key};
                     } else {
                         print "missing signature parameter: {$key}";
                     }
                 }
                 // hex encode an HMAC-SHA1 string
                 $signature = base64_encode(hash_hmac('sha1', $base_string, SETTING::linkedInSecret, true));
                 // check if our signature matches the cookie's
                 if ($signature == $credentials->signature) {
                     //Signature is authentic, use the stuff
                     require_once 'linkedin_3.3.0.class.php';
                     $linkedin = new LinkedIn(array('appKey' => SETTING::linkedInAPI, 'appSecret' => SETTING::linkedInSecret, 'callbackUrl' => NULL));
                     $tokens = $linkedin->exchangeToken($credentials->access_token);
                     //Find member_id
                     $sql = "SELECT id, nonce  FROM Users WHERE linkedin_id = '" . $credentials->member_id . "'";
                     $result = mysql_query($sql);
                     if (mysql_num_rows($result) == 1) {
                         $row = mysql_fetch_assoc($result);
                         $userId = $row["id"];
                         $this->setSession($row["id"], $row["nonce"]);
                         //UPDATE LinkedinToken
                         $sql = "UPDATE Users SET linkedin_token = '" . $tokens["linkedin"]["oauth_token"] . "', linkedin_token_secret = '" . $tokens["linkedin"]["oauth_token_secret"] . "' WHERE " . $this->USER_ID . " = " . $userId;
                         $query = mysql_query($sql);
                     }
                     //No member found, check if user already exists based upon usernam = email
                     if (mysql_num_rows($result) == 0) {
                         //print_r($tokens);
                         $linkedin->setTokenAccess($tokens["linkedin"]);
                         $result = $linkedin->profile("~:(email-address)?format=json");
                         $result = json_decode($result["linkedin"], true);
                         $sql = "SELECT id, nonce FROM Users WHERE " . $this->USER_NAME . " = '" . $result["emailAddress"] . "'";
                         $query = mysql_query($sql);
                         if (mysql_num_rows($query) == 1) {
                             //Combination is known
                             $row = mysql_fetch_assoc($query);
                             //print_r($row);
                             $userId = $row["id"];
                             $this->setSession($row["id"], $row["nonce"]);
                             //UPDATE LinkedinToken
                             $sql = "UPDATE Users SET linkedin_token = '" . $tokens["linkedin"]["oauth_token"] . "', linkedin_token_secret = '" . $tokens["linkedin"]["oauth_token_secret"] . "', linkedin_id = '" . $credentials->member_id . "' WHERE " . $this->USER_ID . " = " . $userId;
                             $query = mysql_query($sql);
                             //Perform import of LinkedIn data
                             require_once "user.class.php";
                             $user = new user($userId, $this->errorClass, $this->notificationClass);
                             $user->getLinkedInData();
                         } else {
                             //Combination is not known, create new profile if stated
                             if ($this->repository->get_data("linkedinRegister") == 1) {
                                 $email = $result["emailAddress"];
                                 $nonce = $this->create_nonce();
                                 $user_ip = $this->repository->get_data('userIPv4');
                                 $email_hash = $this->hash_password($email, $nonce);
                                 //Define the reference number for the user
                                 $sql = "SELECT MAX(`reference_number`) as maximum FROM Users WHERE created_on >= '" . date("Y") . "-01-01' AND created_on <= '" . date("Y") . "-12-31'";
                                 $result = mysql_fetch_assoc(mysql_query($sql));
                                 $reference_number = $result["maximum"] + 1;
                                 //Create public profile hash
                                 $profile_hash = $this->hash_password($reference_number, $nonce);
                                 //INSERT NEW USER TO DB
                                 $query = sprintf("INSERT INTO " . $this->USER_TABLE . " (" . $this->USER_NAME . ", " . $this->USER_IP_REGISTER . ", " . $this->USER_CREATION . ", confirm_hash, nonce, account_status, reference_number, profile_hash) VALUES ('%s','%s', NOW(), '%s','%s', 0,'%s','%s')", $email, $user_ip, $email_hash, $nonce, $reference_number, $profile_hash);
                                 $result = mysql_query($query);
                                 if (!$result) {
                                     $this->errorClass->add_error(202);
                                 } else {
                                     //INSERT Clientnr to DB
                                     $sql = "SELECT * FROM Users WHERE id = " . mysql_insert_id();
                                     $result = mysql_query($sql);
                                     $user = mysql_fetch_assoc($result);
                                     $date = strtotime($user["created_on"]);
                                     $sql = "UPDATE Users SET client_number = \"K" . date('ym', $date) . "" . sprintf('%04d', $user["reference_number"]) . "\" WHERE id = " . $user["id"];
                                     $result = mysql_query($sql);
                                     $this->setSession($user["id"], $nonce);
                                     //UPDATE LinkedinToken
                                     $sql = "UPDATE Users SET linkedin_token = '" . $tokens["linkedin"]["oauth_token"] . "', linkedin_token_secret = '" . $tokens["linkedin"]["oauth_token_secret"] . "', linkedin_id = '" . $credentials->member_id . "' WHERE " . $this->USER_ID . " = " . $user["id"];
                                     $query = mysql_query($sql);
                                     //Perform import of LinkedIn data
                                     require_once "user.class.php";
                                     $user = new user($user["id"], $this->errorClass, $this->notificationClass);
                                     $user->getLinkedInData();
                                     header("Location:" . Setting::baseUrl . "/users/complete_account.php");
                                     exit;
                                 }
                             } else {
                                 $this->notificationClass->add_note("Het emailadres die je gebruikt bij LinkedIn is niet bij ons bekend. Log in met je emailadres en wachtwoord en koppel je profiel met LinkedIn in je accountinstellingen of <a href=\"index.php?linkedinLogin=1&linkedinRegister=1\">registreer</a> met je LinkedIn account");
                             }
//.........这里部分代码省略.........
开发者ID:haverver,项目名称:SVN,代码行数:101,代码来源:class.login.php

示例8: SimpleXMLElement

                echo $_SERVER['PHP_SELF'];
                ?>
" method="get">
              <input type="hidden" name="<?php 
                echo LINKEDIN::_GET_TYPE;
                ?>
" id="<?php 
                echo LINKEDIN::_GET_TYPE;
                ?>
" value="revoke" />
              <input type="submit" value="Revoke Authorization" />
            </form>


            <?php 
                $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 {
                    // request failed
                    echo "Error retrieving profile information:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>";
                }
            } else {
                // user isn't connected
                ?>
            <form id="linkedin_connect_form" action="<?php 
                echo $_SERVER['PHP_SELF'];
                ?>
" method="get">
              <input type="hidden" name="<?php 
开发者ID:praveenpgoswami,项目名称:codeigniter_project,代码行数:31,代码来源:demo.php

示例9: 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);
//.........这里部分代码省略.........
开发者ID:njhamann,项目名称:LInkedIn-Resume-Generator,代码行数:101,代码来源:marketing.php

示例10: loadLinkedInFriends

 private function loadLinkedInFriends()
 {
     // If we have loaded the user's LinkedIn friends already in the last 12 hours, just reuse them
     $cacheQ = $this->db->prepare('SELECT facebook_id, linkedin_id, twitter_id, name FROM temp_friend WHERE temp_friends_id = (SELECT id FROM temp_friends WHERE linkedin_id = :linkedin_id AND time > DATE_SUB(NOW(), INTERVAL 12 HOUR) ORDER BY time DESC LIMIT 1)');
     $cacheQ->execute(array(':linkedin_id' => $this->userDetails['id']));
     $cache = $cacheQ->fetchAll(PDO::FETCH_ASSOC);
     $this->printCachedFriendsIfSet($cache);
     // Load friends from LinkedIn
     $API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => '');
     $OBJ_linkedin = new LinkedIn($API_CONFIG);
     $OBJ_linkedin->setTokenAccess(unserialize($this->userDetails['access_token']));
     try {
         $linkedInFriends = $OBJ_linkedin->profile('id=' . $this->userDetails['id'] . '/connections:(id,first-name,last-name)');
     } catch (ErrorException $e) {
         $this->printAccessTokenError($e);
     }
     if ($linkedInFriends['success'] === TRUE) {
         $linkedInFriends['linkedin'] = new SimpleXMLElement($linkedInFriends['linkedin']);
     }
     // Catch LinkedIn error
     if ($linkedInFriends['success'] !== TRUE || $linkedInFriends['linkedin']->getName() != 'connections') {
         $this->printAccessTokenError('Success !== TRUE');
     }
     // No friends? :-(
     if (count($linkedInFriends['linkedin']->children()) == 0) {
         $json['result'] = 'false';
         echo json_encode($json);
         exit;
     }
     // Cache the LinkedIn friends so we don't have to query the LinkedIn API again soon
     $insert = $this->db->prepare('INSERT INTO temp_friends (time, linkedin_id) VALUES (NOW(), :linkedin_id)');
     $insert->execute(array(':linkedin_id' => $this->userDetails['id']));
     $tempFriendsId = $this->db->lastInsertId();
     $friendIds = array();
     foreach ($linkedInFriends['linkedin']->person as $friend) {
         $id = (string) $friend->id;
         $friendIds[] = $this->db->quote($id);
         $json['friends'][$id]['linkedInId'] = $id;
         $json['friends'][$id]['name'] = $friend->{'first-name'} . ' ' . $friend->{'last-name'};
     }
     $extraInfoQ = $this->db->prepare('SELECT f.id as facebookId, l.id as linkedInId, t.id as twitterId FROM linkedin l, person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = l.person_id AND l.id IN (' . implode(',', $friendIds) . ')');
     $extraInfoQ->execute();
     $extraInfo = $extraInfoQ->fetchAll(PDO::FETCH_ASSOC);
     $json = $this->updateTemporaryFriends($json, $extraInfo, $tempFriendsId);
     // Delete old caches of friend list
     $clearQ = $this->db->prepare('DELETE FROM temp_friends WHERE linkedin_id = :linkedin_id AND time < DATE_SUB(NOW(), INTERVAL 12 HOUR)');
     $clearQ->execute(array(':linkedin_id' => $this->userDetails['id']));
     // Output successful result
     $json['result'] = 'true';
     $json['time'] = Debug::getInstance()->getTimeElapsed();
     echo json_encode($json);
     exit;
 }
开发者ID:chitrakojha,项目名称:introduceme,代码行数:53,代码来源:AjaxLoadFriends.php

示例11: get_li_profile

function get_li_profile()
{
    $API_CONFIG = array('appKey' => bb_get_option('li_app_id'), 'appSecret' => bb_get_option('li_secret'), 'callbackUrl' => NULL);
    $me = null;
    try {
        $_SESSION['oauth']['linkedin']['authorized'] = isset($_SESSION['oauth']['linkedin']['authorized']) ? $_SESSION['oauth']['linkedin']['authorized'] : FALSE;
        if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
            //bb_die("Authorized, accessing profile");
            $OBJ_linkedin = new LinkedIn($API_CONFIG);
            //bb_die($_SESSION['oauth']['linkedin']['access']);
            $OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
            $OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_XML);
            // if successful authorization proceed to retrieve user information
            $response = $OBJ_linkedin->profile('~:(id,first-name,last-name,industry,picture-url,headline,public-profile-url)');
            if ($response['success'] === TRUE) {
                $response['linkedin'] = new SimpleXMLElement($response['linkedin']);
                $me = $response['linkedin'];
            } else {
                bb_die("profiled request failed.");
            }
        }
    } catch (LinkedInException $e) {
        error_log($e);
    }
    return $me;
}
开发者ID:nma,项目名称:linkedin-connect,代码行数:26,代码来源:connect.php

示例12: 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');
 }
开发者ID:praveenpgoswami,项目名称:codeigniter_project,代码行数:90,代码来源:user.php

示例13: 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;
 }
开发者ID:riverans,项目名称:manage-expenses,代码行数:66,代码来源:AuthorizationComponent.php

示例14: LinkedIn

<?php

header('Content-type: application/json');
require '../config/keys.php';
require '../lib/linkedin/linkedin_3.2.0.class.php';
$API_CONFIG = $linkedin['config'];
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess($linkedin['access']);
$OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_JSON);
$json = $OBJ_linkedin->profile('~:(first-name,last-name,formatted-name,industry,skills,summary,specialties,positions,picture-url,educations,interests,headline,phone-numbers,email-address,member-url-resources)');
$info = json_decode($json['linkedin']);
$node = array('name' => $info->formattedName, 'headline' => $info->headline, 'picture_url' => $info->pictureUrl, 'summary' => $info->summary, 'work_history' => $info->positions->values, 'meta' => 'Powered by LinkedIn', 'profile_url' => 'http://www.linkedin.com/in/njhamann');
if ($json['success'] === TRUE) {
    if (isset($_GET['raw']) && $_GET['raw'] == '1') {
        echo json_encode($info);
    } else {
        echo json_encode($node);
    }
}
开发者ID:njhamann,项目名称:social-cms,代码行数:19,代码来源:linkedin.php

示例15: link

 /**
  * Similar to onAuthenticate, except we already have a logged in user, we're just linking accounts
  *
  * @param   array  $options
  * @return  void
  */
 public function link($options = array())
 {
     $jsession = App::get('session');
     // Set up linkedin configuration
     $linkedin_config['appKey'] = $this->params->get('api_key');
     $linkedin_config['appSecret'] = $this->params->get('app_secret');
     // Create Object
     $linkedin_client = new LinkedIn($linkedin_config);
     if (!Request::getVar('oauth_verifier', NULL)) {
         // User didn't authorize our app, or, clicked cancel
         App::redirect(Route::url('index.php?option=com_members&id=' . User::get('id') . '&active=account'), Lang::txt('PLG_AUTHENTICATION_LINKEDIN_MUST_AUTHORIZE_TO_LOGIN', App::get('sitename')), 'error');
     }
     // 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
     $request = $jsession->get('linkedin.oauth.request');
     $reply = $linkedin_client->retrieveTokenAccess($request['oauth_token'], $request['oauth_token_secret'], Request::getVar('oauth_verifier'));
     if ($reply['success'] === TRUE) {
         // The request went through without an error, gather user's 'access' tokens
         $jsession->set('linkedin.oauth.access', $reply['linkedin']);
         // Set the user as authorized for future quick reference
         $jsession->set('linkedin.oauth.authorized', TRUE);
     } else {
         return new Exception(Lang::txt('Access token retrieval failed'), 500);
     }
     if ($jsession->get('linkedin.oauth.authorized') == TRUE) {
         $linkedin_client->setTokenAccess($jsession->get('linkedin.oauth.access'));
         // Get the linked in profile
         $profile = $linkedin_client->profile('~:(id,first-name,last-name,email-address)');
         $profile = $profile['linkedin'];
         // Parse the profile XML
         $profile = new SimpleXMLElement($profile);
         // Get the profile values
         $li_id = $profile->{'id'};
         $username = (string) $li_id;
         // (make sure this is unique)
         $hzad = \Hubzero\Auth\Domain::getInstance('authentication', 'linkedin', '');
         // Create the link
         if (\Hubzero\Auth\Link::getInstance($hzad->id, $username)) {
             // This linkedin account is already linked to another hub account
             App::redirect(Route::url('index.php?option=com_members&id=' . User::get('id') . '&active=account'), Lang::txt('PLG_AUTHENTICATION_LINKEDIN_ACCOUNT_ALREADY_LINKED'), 'error');
         } else {
             $hzal = \Hubzero\Auth\Link::find_or_create('authentication', 'linkedin', null, $username);
             $hzal->user_id = User::get('id');
             $hzal->email = (string) $profile->{'email-address'};
             $hzal->update();
         }
     } else {
         // User didn't authorize our app, or, clicked cancel
         App::redirect(Route::url('index.php?option=com_members&id=' . User::get('id') . '&active=account'), Lang::txt('PLG_AUTHENTICATION_LINKEDIN_MUST_AUTHORIZE_TO_LINK', Config::get('sitename')), 'error');
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:57,代码来源:linkedin.php


注:本文中的LinkedIn::profile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。