title: PHP Paypal API not working
body: <p>Can someone please tell me whats wrong with this code.</p>
  
  <p>I'm not getting complete from paypal.</p>
  
  <p>Once i paied i should be getting to this <code>if (strcmp ($res, "VERIFIED") == 0)</code> but i'm not.</p>
  
  <pre><code>$req = 'cmd=_notify-validate';
  foreach ($_POST as $key =&gt; $value)
  {
      $value = urlencode(stripslashes($value));
      $req .= "&amp;$key=$value";
  }
  
  $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  
  $mode = $paymod_data['MODULE_PAYMENT_PAYPAL_TESTMODE'];
  
  if ($mode == 'test')
  {
      $fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
  }
  else
  {
      $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
  }
  
  if (!$fp)
  {
      // HTTP ERROR
       die ("Error");
  }
  else 
  {   
      fputs ($fp, $header . $req);
      while (!feof($fp))
      {
          $res = fgets ($fp, 1024);
          if (strcmp ($res, "VERIFIED") == 0)
          {
              processing ( $_POST );      
          }
          else if (strcmp ($res, "INVALID") == 0)
          {
          }
      }
      fclose ($fp);
  }
  </code></pre>