note 32436 added to function.fsockopen

From: Date: Tue, 27 May 2003 21:23:55 +0000
Subject: note 32436 added to function.fsockopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-49113@lists.php.net to get a copy of this message
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; ?> ---- Manual Page -- http://www.php.net/manual/en/function.fsockopen.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32436 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32436&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32436&report=yes

« previous php.notes (#49113) next »