# 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)"); echo '<pre>'; echo 'My Profile Info'; echo $xml_response; echo '<br />'; echo '</pre>'; $search_response = $linkedin->search("?company-name=facebook&count=10"); //$search_response = $linkedin->search("?title=software&count=10"); //echo $search_response; $xml = simplexml_load_string($search_response); echo '<pre>'; echo 'Look people who worked in facebook'; print_r($xml); echo '</pre>';
} else { // update retrieval failed echo "Error retrieving updates:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>"; } ?> <hr /> <h2 id="search">People Search:</h2> <p>All 1st degree connections living in the San Francisco Bay Area (returned in JSON format):</p> <?php $OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_JSON); $query = '?facet=location,us:84&facet=network,F'; $response = $OBJ_linkedin->search($query); if ($response['success'] === TRUE) { //$response['linkedin'] = new SimpleXMLElement($response['linkedin']); echo "<pre>" . print_r($response['linkedin'], TRUE) . "</pre>"; } else { // people search retrieval failed echo "Error retrieving search results:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>"; } ?> <hr /> <h2 id="content">Creating / Sharing Content</h2> <h3 id="content_update">Post Network Update:</h3> <form id="linkedin_nu_form" action="<?php
<?php require_once 'linkedin.php'; # Use this to used already retrieved access token credentials for testing. $consumer_key = ""; $consumer_secret = ""; $access_token = ""; $access_token_secret = ""; # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback $linkedin = new LinkedIn($consumer_key, $consumer_secret, "oob"); $linkedin->debug = true; $linkedin->access_token = new OAuthConsumer($access_token, $access_token_secret, 1); # Let's do a search! $search_response = $linkedin->search("?company=Google&count=10"); echo $search_response;