title: How to get an oauth_token with oAuth in PHP
body: <p>I'm trying to authenticate using OAuth in <a href="http://docs.openx.com/api/#api_authentication.html" rel="nofollow">OpenX</a> <strong>(site does not render well in chrome. Use iexplore or safari.)</strong></p>
  
  <p>This is my piece of code</p>
  
  <pre><code># Login
  $url = "https://sso.openx.com/api/index/token";
  $post = http_build_query( array(  'Access Token URL' =&gt; 'https://sso.openx.com/api/index/token',
                  'Authorize URL' =&gt; 'https://sso.openx.com/login/login',
                  'callbackUrl' =&gt; 'oob',
                  'Consumer Key' =&gt; $key,
                  'Consumer Secret' =&gt; $secret,
                  'OAuth Realm' =&gt; $realm,
                  'Request Token URL' =&gt; 'https://sso.openx.com/api/index/initiate',
                  'Signature Method' =&gt; 'HMAC-SHA1 ',
                  'Version' =&gt; '1.0a ') );
  
  $curl = curl_init($url);
  
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($resource, CURLOPT_POSTFIELDS, $post);
  curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  curl_setopt($curl, CURLOPT_VERBOSE, 1);
  curl_setopt($curl, CURLOPT_HEADER, 1);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  
  $json_response = curl_exec($curl);
  var_dump($json_response);
  curl_close($curl);
  
  $authObj = json_decode($json_response);
  </code></pre>
  
  <p>And, according to the linked documentation, I should be expecting an <em>oauth_token</em> and <em>oauth_verifier</em>:</p>
  
  <blockquote>
    <p>1.Set the callbackUrl to oob (out-of-band), which tells the OAuth server that you are not redirecting a user. The OAuth Server returns the request token.</p>
  </blockquote>
  
  <p>but instead I'm getting:</p>
  
  <blockquote>
    <p>HTTP/1.1 400 Bad Request - Invalid Request: Missing parameters</p>
  </blockquote>
  
  <p>Am I doing something obviously wrong here that I am missing? Am I misunderstanding something in the linked documentation?</p>
  
  <p>Any sort of help is welcome, either aimed at the problem itself or to the way it's been presented; answers, hints, ideas, corrections, etc.</p>
  
  <p>Thank you.</p>