title: How to get response in php from papal IPN
body: <p>I have created an paypal's ipn response &amp; now i want to know to how can i get the response in php by using <strong>GET</strong> or <strong>POST</strong>. I am doing this for the first time . So, i have no idea what to do next when i get the ipn response.
  Suggest some method to capture paypal IPN data properly.
  Thanks in advance.       </p>
  
  <pre><code>&lt;?php
      class Paypal_IPN
      {
          public function __construct($mode= 'live')
          {
              //https://www.paypal.com/cgi-bin/webscr
              if($mode == 'live'){
              $this-&gt;_url = 'https://www.paypal.com/cgi-bin/webscr';}
              else{
              $this-&gt;_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';  }  
  
  
          }
  
          public function run()
          {
              $postFields = 'cmd=_notify-validate';
  
  
              foreach($_POST as $key =&gt; $value)
              {
                  $postFields .= "&amp;$key=".urlencode($value);
              }
  
              $ch = curl_init();
  
              curl_setopt($ch, CURLOPT_URL, $this-&gt;_url);
              curl_setopt($ch, CURLOPT_POST, true);
              curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              curl_setopt($ch, CURLOPT_HEADER, false);
              curl_setopt($ch, CURLOPT_TIMEOUT, 30);
              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  
              $result = curl_exec($ch);
  
              curl_close($ch);
  
              $fh = fopen('result.txt','w');
              fwrite($fh, $result . '--' . $postFields);
              fclose($fh);
              echo "abc";
              echo $result; 
          }
  
      }
  
  ?&gt;
  </code></pre>