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 8060207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:54:49+00:00 2026-06-05T09:54:49+00:00

Hey I’m trying to use LinkedIn’s OAuth in PHP. I’m stuck at the first

  • 0

Hey I’m trying to use LinkedIn’s OAuth in PHP. I’m stuck at the first step of getting a request token. All I know is you post some values to their server and get your token back. So i post the documented args to ‘https://api.linkedin.com/uas/oauth/requestToken’ and I get slapped with a 400 error.

here’s the request:

$postArr = array();
//$postArr["oauth_callback"] = ""; idk they said this was optional...
$postArr["oauth_consumer_key"] = "ForBritishEyesOnly"; //is this the application secret key or the api key?
$postArr["oauth_nonce"] = "UltraRandomNonceFTW";
$postArr["oauth_timestamp"] = time();
$postArr["oauth_signature_method"] = "HMAC-SHA1"; //lolwut
$postArr["oauth_version"] = "1.0";

$params = array('http'=>array('method'=>'post','content'=>http_build_query($postArr)));
$context = stream_context_create($params);
$stream = file_get_contents('https://api.linkedin.com/uas/oauth/requestToken', false, $context);

I don’t think my POST args are correct but ANY help is very appreciated — I just don’t want resort to use someone else’s library to solve this.

——-EDIT: ATTEMPT 2 per James’ input ———

ok so here im making a call to the test link you sent me. i’m actually able to get a response back, but it doesnt like my signature (big surprise, i know). So just how bad did I screw up the encryption?

//setup GET args
$url = "http://term.ie/oauth/example/request_token.php?";
$url .= "oauth_version=1.0&";
$url .= "oauth_nonce=" . rand(0, 100000) . "&";
$url .= "oauth_timestamp=" . time() . "&";
$url .= "oauth_consumer_key=key&";
$url .= "oauth_signature_method=HMAC-SHA1&";

//encrypt the request according to 'secret'
$sig = urlencode(base64_encode(hash_hmac("sha1", $url, "secret")));

//append the url encoded signature as the final GET arg
$url .= "oauth_signature=" . $sig;

//do it to it
echo file_get_contents($url);

EDIT by James

Try:

//setup GET args
$url = "http://term.ie/oauth/example/request_token.php?";
$url .= "oauth_consumer_key=key&";
$url .= "oauth_nonce=" . rand(0, 100000) . "&";
$url .= "oauth_signature_method=HMAC-SHA1&";
$url .= "oauth_timestamp=" . time() . "&";
$url .= "oauth_version=1.0&";
  • 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-06-05T09:54:51+00:00Added an answer on June 5, 2026 at 9:54 am

    I’m on cloud nine. Decided to revisit this problem and got it to work. Here is some very bare bones PHP to build a token request for LinkedIn (it outputs an anchor tag)

    <?php
    $endpoint = "https://api.linkedin.com/uas/oauth/requestToken";
    $key = "YourAPIKey";
    $secret = "YourAPISecret";
    $params = array( 
        "oauth_version" => "1.0", 
        "oauth_nonce" => time(), 
        "oauth_timestamp" => time(), 
        "oauth_consumer_key" => $key, 
        "oauth_signature_method" => "HMAC-SHA1" 
    );
    function SortedArgumentString($inKV)
    {
        uksort($inKV, 'strcmp');
        foreach ($inKV as $k => $v)
            $argument[] = $k."=".$v;
        return implode('&', $argument); 
    }
    $baseString = "GET&" . urlencode($endpoint) . "&" . urlencode(SortedArgumentString($params));
    $params['oauth_signature'] = urlencode(base64_encode(hash_hmac('sha1', $baseString, $secret."&", TRUE))); 
    echo "<a href=\"" . $endpoint . "?" . SortedArgumentString($params) . "\">Get Token<a/><br/>"; 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all i have a JSFiddle that i have been working on with trying
Hey all i am wondering why my code below is only writing the first
Hey all i am trying to figure out what i am doing incorrectly here.
Hey all. I've been been trying to figure this out for a while now.
Hey i want to use php to redirect a user to a url depending
Hey all i am wondering why i am getting this error with the following
Hey all. I'm trying to see about handling events in a console application. I
hey guys i know this may sound stupid, but i am stuck with this
Hey all i am trying to figure out how to resize an image that
Hey all i'm getting hung up on how to search a database for a

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.