title: Magento REST API Error 500
body: <p>I am trying to get product information through Magento REST API; but results an error starting “ [message:protected] => Invalid auth/bad request (got a 500, expected HTTP/1.1 20X or a redirect)
  …....................”
  No idea why this occurs; can anybody please help me on this ? 
  My code follows:</p>
  
  <pre><code>$callbackUrl = "http://myhostcom/current_script.php";
  $temporaryCredentialsRequestUrl = "http://myhostcom/oauth/initiate?oauth_callback=" .               urlencode($callbackUrl);
  $adminAuthorizationUrl = 'http://myhostcom/oauth/authorize';
  $accessTokenRequestUrl = 'http://myhostcom/oauth/token';
  $apiUrl = 'http://myhostcom/api/rest';
  $consumerKey = 'xxxxxx';
  $consumerSecret = 'xxxxxxxxxxx';
  echo '&lt;pre/&gt;';
  session_start();
  if (!isset($_GET['oauth_token']) &amp;&amp; isset($_SESSION['state']) &amp;&amp; $_SESSION['state'] == 1) {
      $_SESSION['state'] = 0;
  }
  try {
      $authType = ($_SESSION['state'] == 2) ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
      $oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
      $oauthClient-&gt;enableDebug();
      $oauthClient-&gt;disableSSLChecks();
  
  
  if (!isset($_GET['oauth_token']) &amp;&amp; !$_SESSION['state']) { 
      $requestToken = $oauthClient-&gt;getRequestToken($temporaryCredentialsRequestUrl);
      $_SESSION['secret'] = $requestToken['oauth_token_secret'];
      $_SESSION['state'] = 1; 
      header('Location: ' . $adminAuthorizationUrl . '?oauth_token=' . $requestToken['oauth_token']);
      exit;
  } else if ($_SESSION['state'] == 1) {      
      $oauthClient-&gt;setToken($_GET['oauth_token'], $_SESSION['secret']);
      $accessToken = $oauthClient-&gt;getAccessToken($accessTokenRequestUrl);
      $_SESSION['state'] = 2;
      $_SESSION['token'] = $accessToken['oauth_token'];
      $_SESSION['secret'] = $accessToken['oauth_token_secret'];
      header('Location: ' . $callbackUrl);
      exit;
  } else { 
      $oauthClient-&gt;setToken($_SESSION['token'], $_SESSION['secret']);
      $resourceUrl = $apiUrl."/products/465"; 
      $oauthClient-&gt;fetch($resourceUrl);
      $productsList = json_decode($oauthClient-&gt;getLastResponse());
      print_r($productsList);
  }
  } catch (OAuthException $e) {
      print_r($e);
  }
  </code></pre>
  
  <p>Thanks.</p>