title: How do I get a LinkedIn request token?
body: <p>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.</p>
  
  <p>here's the request:</p>
  
  <pre><code>$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'=&gt;array('method'=&gt;'post','content'=&gt;http_build_query($postArr)));
  $context = stream_context_create($params);
  $stream = file_get_contents('https://api.linkedin.com/uas/oauth/requestToken', false, $context);
  </code></pre>
  
  <p>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. </p>
  
  <p>-------EDIT: ATTEMPT 2 per James' input ---------</p>
  
  <p>ok so here im making a call to the test link you sent me. i'm <em>actually</em> 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?</p>
  
  <pre><code>//setup GET args
  $url = "http://term.ie/oauth/example/request_token.php?";
  $url .= "oauth_version=1.0&amp;";
  $url .= "oauth_nonce=" . rand(0, 100000) . "&amp;";
  $url .= "oauth_timestamp=" . time() . "&amp;";
  $url .= "oauth_consumer_key=key&amp;";
  $url .= "oauth_signature_method=HMAC-SHA1&amp;";
  
  //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);
  </code></pre>
  
  <p>EDIT by James</p>
  
  <p>Try:</p>
  
  <pre><code>//setup GET args
  $url = "http://term.ie/oauth/example/request_token.php?";
  $url .= "oauth_consumer_key=key&amp;";
  $url .= "oauth_nonce=" . rand(0, 100000) . "&amp;";
  $url .= "oauth_signature_method=HMAC-SHA1&amp;";
  $url .= "oauth_timestamp=" . time() . "&amp;";
  $url .= "oauth_version=1.0&amp;";
  </code></pre>