note 32436 deleted from function.fsockopen by danbrown

From: Date: Mon, 18 May 2009 01:58:48 +0000
Subject: note 32436 deleted from function.fsockopen by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155614@lists.php.net to get a copy of this message
Note Submitter: annettetruong at yahoo dot com ---- I need to use Paypal IPN and can't use fsockopen() or cURL. I'm trying the following as a workaround to using fsockopen() which creates a hidden form that is automatically submitted upon page load, with the final verification step from Paypal caught in the iframe. I would appreciate comments on the pitfalls to this method. About Paypal IPN: http://www.paypal.com/cgi-bin/webscr?cmd=p/xcl/rec/ipn-intro-outside Thanks, Annette. <?php // Create one additional form element called 'cmd' $hiddenForm = "<input type='hidden' name='cmd' value='_notify-validate'>\n"; // Assemble page structure $pageBody = "<body onLoad='document.all.myForm.submit();'>"; $pageBody .= "<h2>IPN Results</h2>"; // Look at values sent via POST. // Add to hidden form in same order. foreach ($_POST as $key => $value) { $hiddenForm .= "<input type='hidden' name='".$key."' value='".$value."'>\n"; // Display everything on the page for inspection. echo $key.": ".$value."<br>\n"; } // Assemble Paypal IPN hidden form. $hiddenForm = "<form name='myForm' method='POST' action='https://www.paypal.com/cgi-bin/webscr' target='myFrame'>\n".$hiddenForm."</form>\n<br>"; // Display helpful message about iframe. $pageBody .= "The frame below will contain the IPN response: VERIFIED or INVALID.<br>\n"; // Create iframe to catch results of automatic // form submission. This frame should // display 'VERIFIED' or 'INVALID'. If it shows // a paypal page then something went wrong. $iFrame = "<iframe name='myFrame'></iframe><br>\n"; $pageBody .= $hiddenForm; $pageBody .= $iFrame; $pageBody .= "</body></html>\n"; // Display page that contains automatic form // submission with embedded iframe. echo $pageBody; ?>

« previous php.notes (#155614) next »