Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6599821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:32:27+00:00 2026-05-25T18:32:27+00:00

I’m trying to do a very basic setup of LinkedIn – accessing public profile

  • 0

I’m trying to do a very basic setup of LinkedIn – accessing public profile data about people.

I’ve tried several ways of accessing with oAuth over several hours. I’m not getting anywhere.

All the existing class structures et’al seem to help with accessing a user’s account to post, or add friends, find a fish etc. I don’t need any of that. I just want to get basic profile data.

Some code of latest attempts; but I don’t get it past here:-

$consumer = new OAuthConsumer($apiKey, $apiSecret);
$signature_method = new OAuthSignatureMethod_HMAC_SHA1();
$req_req = OAuthRequest::from_consumer_and_token($consumer, NULL, "GET", $linkedInURL . "/uas/oauth/requestToken");
$req_req->sign_request($signature_method, $consumer, NULL);         
$signed_url = $req_req->to_url();   

That should gives me a signed request of:-

https://api.linkedin.com/uas/oauth/requestToken?oauth_consumer_key=xxx&oauth_nonce=xx&oauth_signature=xxxx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1316530337&oauth_version=1.0

Obviously, that’s not what I need to get data. But, just out of interest I checked the URL with the API data request, as such:-
http://api.linkedin.com/v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fchrisvoss:public?oauth_consumer_key=xxx&oauth_nonce=xxx&oauth_signature=xxx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1316529463&oauth_version=1.0

And got :-

<error>
 <status>401</status>
  <timestamp>1316531835564</timestamp>
  <request-id>L8A1M85MWN</request-id>
  <error-code>0</error-code>
  <message>
        [unauthorized].OAU:tm6i3ke827xz|*01|*01|*01:1316529463:MSFHS3f4iaG9pg2gWYlf22W4NPo=
     </message>
</error>

I’m just a bit clueless here. I know everyone says it’s tears to implement oAuth and Linkedin. But, I don’t need half of what most need, so how do I get to the basic data is only my question.

Thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:32:28+00:00Added an answer on May 25, 2026 at 6:32 pm
    Try To Use the following code
    
       session_start();
    require_once("OAuth.php");  
    
    
    
    $domain = "https://api.linkedin.com/uas/oauth";
    $sig_method = new OAuthSignatureMethod_HMAC_SHA1();
    
    
    
    $test_consumer = new OAuthConsumer("DEHYU99peS88wDDAFOcSm3Af5VO1tdrdgq1xPu_fpSSjsqPcoeABUs_NCyY33WIH", "gZrZr2-7s80CEsGpAHqFgREMbRWkR3L8__tkje3j-oKtIDlmn5KCR6bXD8i0HFp1", NULL);
    $callback = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?action=getaccesstoken";
    
    
    
    # First time through, get a request token from LinkedIn.
    if (!isset($_GET['action'])) {
    
            $req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "POST", $domain . "/requestToken");
            $req_req->set_parameter("oauth_callback", $callback); # part of OAuth 1.0a - callback now in requestToken
            $req_req->sign_request($sig_method, $test_consumer, NULL);
    
            $ch = curl_init();
            // make sure we submit this as a post
            curl_setopt($ch, CURLOPT_POSTFIELDS, ''); //New Line
    
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($ch, CURLOPT_HTTPHEADER,array (
                    $req_req->to_header()
            ));
            curl_setopt($ch, CURLOPT_URL, $domain . "/requestToken");
            curl_setopt($ch, CURLOPT_POST, 1);
            $output = curl_exec($ch);
            curl_close($ch);
    
            //print_r($req_req);  //<---- add this line
    
            //print("$output\n");  //<---- add this line
    
            parse_str($output, $oauth);
    
    
            # pop these in the session for now - there's probably a more secure way of doing this! We'll need them when the callback is called.
    
            $_SESSION['oauth_token'] = $oauth['oauth_token'];
            $_SESSION['oauth_token_secret'] = $oauth['oauth_token_secret'];
    
    
    
            # Redirect the user to the authentication/authorisation page. This will authorise the token in LinkedIn
            Header('Location: ' . $domain . '/authorize?oauth_token=' . $oauth['oauth_token']);
            #print 'Location: ' . $domain . '/authorize?oauth_token=' . $oauth['oauth_token']; // <---- add this line
    
    
    } else {
            # this is called when the callback is invoked. At this stage, the user has authorised the token.
            # Now use this token to get a real session token!
    
            //print "oauth_token = [[".$_REQUEST['oauth_token']."]]\n";echo "<br/><br/>";
    
            $req_token = new OAuthConsumer($_REQUEST['oauth_token'], $_SESSION['oauth_token_secret'], 1);
            $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $req_token, "POST", $domain . '/accessToken');
            $acc_req->set_parameter("oauth_verifier", $_REQUEST['oauth_verifier']);  # need the verifier too!
            $acc_req->sign_request($sig_method, $test_consumer, $req_token);
    
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_POSTFIELDS, ''); //New Line
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($ch, CURLOPT_HTTPHEADER,array (
                    $acc_req->to_header()
            ));
            curl_setopt($ch, CURLOPT_URL, $domain . "/accessToken");
            curl_setopt($ch, CURLOPT_POST, 1);
            $output = curl_exec($ch);
            if(curl_errno($ch)){
                echo 'Curl error 1: ' . curl_error($ch);
            }
            curl_close($ch);
            parse_str($output, $oauth);
    
    
            $_SESSION['oauth_token'] = $oauth['oauth_token'];
            $_SESSION['oauth_token_secret'] = $oauth['oauth_token_secret'];
            # Now you have a session token and secret. Store these for future use. When the token fails, repeat the above process.
            //$endpoint = "http://in.linkedin.com/in/intercom"; # need a + symbol here.
            $endpoint = "http://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,industry,educations,site-standard-profile-request)";
            //$req_token = new OAuthConsumer($oauth['oauth_token'], $oauth['oauth_token_secret'], 1);
            $req_token = new OAuthConsumer($oauth['oauth_token'],$oauth['oauth_token_secret'], 1);
            //$profile_req = OAuthRequest::from_consumer_and_token($test_consumer, $req_token, "GET", $endpoint, array("name" => "intercom")); # but no + symbol here!
            $profile_req = OAuthRequest::from_consumer_and_token($test_consumer,$req_token, "GET", $endpoint, array());
            $profile_req->sign_request($sig_method, $test_consumer, $req_token);
    
            $ch = curl_init();
    
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($ch, CURLOPT_HTTPHEADER,array (
                    $profile_req->to_header()
            ));
            curl_setopt($ch, CURLOPT_URL, $endpoint);
            $output = curl_exec($ch);
    
    
            if(curl_errno($ch)){
                echo 'Curl error 2: ' . curl_error($ch);
            }
            curl_close($ch);
            //header ("Content-Type:text/xml");  
            //print $output;
    
            $myFile = $_SERVER['DOCUMENT_ROOT']."/oauth/linkedin.xml";
            $fh = fopen($myFile, 'w') or die("can't open file");
            //$stringData = "Bobby Bopper\n";
            fwrite($fh, $output);
            fclose($fh);
    
            //Initialize the XML parser
            global $currentTag;
            global $profileArray;
            $parser=xml_parser_create();
    
            //Function to use at the start of an element
            function start($parser,$element_name,$element_attrs) {
                $element_name   =   strtolower($element_name);
                global $currentTag;
                $currentTag = $element_name;
                /*switch($element_name) {
                    case "person":
                    $currentTag = $element_name;
                    break;
                    case "headline":
                    echo "headline: ";
                    break;
                    case "school-name":
                    echo "school-name: ";
                    break;
                    case "degree":
                    echo "degree: ";
                    break;
                    case "field-of-study":
                    echo "field-of-study: ";
                }*/
            }
    
            //Function to use at the end of an element
            function stop($parser,$element_name) {}
    
            //Function to use when finding character data
            function char($parser,$data){
    
                //echo $data;
                global $currentTag;
                global $profileArray;
                switch($currentTag) {
    
                    /* case "member-url":
                    if(!isset($profileArray['member-url'])) {
                        $profileArray['member-url'] =   $data;//echo $profileArray['industry'];
                    }
                    break;*/
                     case "id":
                    if(!isset($profileArray['id'])) {
                        $profileArray['id'] =   $data;//echo $profileArray['industry'];
                    }
                    break;
    
                     case "site-standard-profile-request":
                    if(!isset($profileArray['site-standard-profile-request'])) {
                        $profileArray['site-standard-profile-request']  =   $data;//echo $profileArray['industry'];
                    }
                    break;
                    case "first-name":
                    if(!isset($profileArray['first-name'])) {
                        $profileArray['first-name'] =   $data;//echo $profileArray['industry'];
                    }
                    break;
    
                    case "last-name":
                    if(!isset($profileArray['last-name'])) {
                        $profileArray['last-name']  =   $data;//echo $profileArray['industry'];
                    }
                    break;
                    case "industry":
                    if(!isset($profileArray['industry'])) {
                        $profileArray['industry']   =   $data;//echo $profileArray['industry'];
                    }
                    break;
                    case "headline":
                    if(!isset($profileArray['headline'])) {
                        $profileArray['headline']   =   $data;
                    }   
                    break;
                    case "school-name":
                    if(!isset($profileArray['school-name'])) {
                        $profileArray['school-name']    =   $data;
                    }
                    break;
                    case "degree":
                    if(!isset($profileArray['degree'])) {
                        $profileArray['degree'] =   $data;
                    }
                    break;
                    case "field-of-study":
                    if(!isset($profileArray['field-of-study'])) {
                        $profileArray['field-of-study'] =   $data;
                    }
                    break;
                }
            }
    
            //Specify element handler
            xml_set_element_handler($parser,"start","stop");
    
            //Specify data handler
            xml_set_character_data_handler($parser,"char");
    
            //Open XML file
            $fp=fopen($_SERVER['DOCUMENT_ROOT']."/oauth/linkedin.xml","r");
    
            //Read data
            while ($data=fread($fp,4096)) {
                xml_parse($parser,$data,feof($fp)) or
                die (sprintf("XML Error: %s at line %d",
                xml_error_string(xml_get_error_code($parser)),
                xml_get_current_line_number($parser)));
            }
    
            //Free the XML parser
            xml_parser_free($parser);
            print_r($profileArray);
            getCurrentCookieValue($name)
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.