title: Tumblr OAuth using PHP's OAuth class
body: <p>Allright, I'm stumped on this one.</p>
  
  <p>I recently downloaded and installed php's OAuth library here: <a href="http://us3.php.net/manual/en/book.oauth.php" rel="nofollow">http://us3.php.net/manual/en/book.oauth.php</a></p>
  
  <p>Using this, I created some test code to try to connect to my Tumblr account and make a post.</p>
  
  <p>I am able to get the RequestToken and Authorize.  But when I make an actual request I get an error:</p>
  
  <pre><code>Invalid auth/bad request (got a 404, expected HTTP/1.1 20X or a redirect)
  </code></pre>
  
  <p>My request url is in the correct format of <a href="http://api.tumblr.com/v2/blog/account/post" rel="nofollow">http://api.tumblr.com/v2/blog/account/post</a>.  And I'm making a POST request.  So I am not sure why it's returning a 404.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  $req_url = 'http://www.tumblr.com/oauth/request_token';
  $authurl = 'http://www.tumblr.com/oauth/authorize';
  $acc_url = 'http://www.tumblr.com/oauth/access_token';
  
  $conskey = '123';
  $conssec = '456';
  
  session_start();
  
  // In state=1 the next request should include an oauth_token.
  // If it doesn't go back to 0
  if(!isset($_GET['oauth_token']) &amp;&amp; $_SESSION['state']==1) $_SESSION['state'] = 0;
  try {
    $oauth = new OAuth($conskey,$conssec);
    $oauth-&gt;enableDebug();
    if(!isset($_GET['oauth_token']) &amp;&amp; !$_SESSION['state']) {
      $request_token_info = $oauth-&gt;getRequestToken($req_url, 'http://www.domain.com/oauth.php');
      $_SESSION['secret'] = $request_token_info['oauth_token_secret'];
      $_SESSION['state'] = 1;
  
      //Make authorize request with oauth_token
      header('Location: '.$authurl.'?oauth_token='.$request_token_info['oauth_token']);
      exit;
    } else if($_SESSION['state']==1) {
  
      //Callback code
  
      $oauth-&gt;setToken($_GET['oauth_token'],$_SESSION['secret']);
      $access_token_info = $oauth-&gt;getAccessToken($acc_url);
      $_SESSION['state'] = 2;
      $_SESSION['token'] = $access_token_info['oauth_token'];
      $_SESSION['secret'] = $access_token_info['oauth_token_secret'];
  
    } 
  
    //Make tumblr post request
    $oauth-&gt;setToken($_SESSION['token'],$_SESSION['secret']);
    $oauth-&gt;fetch("http://api.tumblr.com/v2/blog/account/post", null, OAUTH_HTTP_METHOD_POST, array('type'=&gt;'text', 'body'=&gt;'this is a test'));  //error happens here
    $json = json_decode($oauth-&gt;getLastResponse());
    print_r($json);
  } catch(OAuthException $E) {
    print_r($E);
  }
  ?&gt;
  </code></pre>
  
  <p>Any hints are greatly appreciated</p>