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


PHP LinkedIn::setResponseFormat方法代码示例

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


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

示例1: 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

示例2: SimpleXMLElement

" value="revoke" />
              <input type="submit" value="Revoke Authorization" />
            </form>
            
            <hr />
            
                        <h2 id="jobs">Jobs API:</h2>
            
            <hr />
            
            <h3 id="jobsBookmarked">Bookmarked Jobs:</h3>

            <p>Jobs that you currently have bookmarked:</p>
            
            <?php 
                $OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_XML);
                $response = $OBJ_linkedin->bookmarkedJobs();
                if ($response['success'] === TRUE) {
                    $bookmarked = new SimpleXMLElement($response['linkedin']);
                    if ((int) $bookmarked['total'] > 0) {
                        $jobs = $bookmarked->{'job-bookmark'};
                        foreach ($jobs as $job) {
                            $jid = $job->job->id;
                            $title = $job->job->position->title;
                            $company = $job->job->company->name;
                            ?>
                  <div style=""><span style="font-weight: bold;"><?php 
                            echo $title . ": " . $company;
                            ?>
</span></div>
                  <div style="margin: 0.5em 0 1em 2em;">
开发者ID:rgummadi,项目名称:ScriptOverflow,代码行数:31,代码来源:jobs.php

示例3: 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

示例4: 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

示例5: test


//.........这里部分代码省略.........
                  */
                 // 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'];
                 } else {
                     throw new LinkedInException('You must load the cURL extension to use this library.');
                 }
                 $_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);
                 } else {
                 }
                 if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
                     // user is already connected
                     $application_key = $OBJ_linkedin->getApplicationKey();
                     $this->data['success'] = FALSE;
                     $response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url)');
                     $this->data['response'] = $response;
                     if ($response['success'] === TRUE) {
                         $this->data['success'] = TRUE;
                         $this->data['status'] = TRUE;
                         $response['linkedin'] = new SimpleXMLElement($response['linkedin']);
                         //var_dump($response['linkedin']);
                         $this->data['response'] = $response['linkedin'];
                     } else {
                         $this->data['status'] = FALSE;
                         // request failed
                     }
                 } else {
                     // user isn't connected
                 }
                 break;
         }
     } catch (LinkedInException $e) {
         // exception raised by library call
         $e->getMessage();
     }
     $this->data['invitation_key'] = array('name' => 'invitation_key', 'id' => 'invitation_key', 'value' => $this->data['invitation_key_val'], 'type' => 'hidden');
     $this->data['first_name'] = array('name' => 'first_name', 'id' => 'first_name', 'type' => 'text', 'value' => $this->form_validation->set_value('first_name'), 'placeholder' => 'First Name', 'required' => 'required');
     $this->data['last_name'] = array('name' => 'last_name', 'id' => 'last_name', 'type' => 'text', 'value' => $this->form_validation->set_value('last_name'), 'placeholder' => 'Last Name', 'required' => 'required');
     $this->data['email'] = array('name' => 'email', 'id' => 'email', 'type' => 'text', 'value' => $this->data['email_val'], 'placeholder' => 'Email', 'required' => 'required', 'readonly' => 'readonly');
     $this->data['password'] = array('name' => 'password', 'id' => 'password', 'type' => 'password', 'value' => $this->form_validation->set_value('password'), 'placeholder' => 'Password', 'required' => 'required');
     $this->data['password_confirm'] = array('name' => 'password_confirm', 'id' => 'password_confirm', 'type' => 'password', 'value' => $this->form_validation->set_value('password_confirm'), 'placeholder' => 'Confirm Password', 'required' => 'required');
     // Render View
     //$this->load->view('auth/create_user', $this->data);
     $this->data['main_content'] = '/auth/signup';
     $this->load->view('includes/tmpl_singlebox', $this->data);
 }
开发者ID:laiello,项目名称:skrapshcnul,代码行数:101,代码来源:auth.php

示例6: 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


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