Rev CGI Post

Bridger Maxwell bridgeyman at gmail.com
Mon Aug 6 02:31:04 EDT 2007


Hey, Never mind, problem solved!  By looking at the PHP script, I was able
to throw together a script to write the POST and receive a response from
PayPal by reading and writing to sockets.  I am still curious to know if I
can use in libURL functions in a Rev CGI though.


   TTFN
     Bridger Maxwell
     www.FieryFerret.com

On 8/5/07, Bridger Maxwell <bridgeyman at gmail.com> wrote:
>
> Hey,  I am trying to make a Rev CGI play nicely with PayPal, and I am
> stuck.  I am trying to implement PayPal's IPN (Instant Payment Notification)
> which sends data to a CGI on my site when a purchase is made.  It does
> this by sending a POST.  My CGI is supposed to POST back to PayPal the
> data PayPal sent me, and a little extra for verification.  As part of the
> second the POST, the PayPal site is supposed to send back either
> "VERIFIED" or "INVALID."  I hope made sense.  :)
>   My CGI is receiving the data, and I try to send a POST back, but no data
> is in the "it" variable or the result.  How do I get the data?  Is the
> POST command available in a CGI?  Should I just do this with my own custom
> sockets?
>
>
> TTFN
>    Bridger Maxwell
>    www.FieryFerret.com
>
>
>
>
> If it helps, I have sample PHP code I am working from, and some of my code
> from the CGI.
>
>
> PHP Code (From PayPal):
> // post back to PayPal system to validate
> $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";
> $fp = fsockopen ('www.paypal.com ', 80, $errno, $errstr, 30);
>
>
> if (!$fp) {
> // HTTP ERROR
> } else {
> fputs ($fp, $header . $req);
> while (!feof($fp)) {
> $res = fgets ($fp, 1024);
> if (strcmp ($res, "VERIFIED") == 0) {
> // process payment
> }
> else if (strcmp ($res, "INVALID") == 0) {
> // log for manual investigation
> }
> }
> fclose ($fp);
> }
>
> My CGI Code:
> put empty into gBuffer
>   REPEAT until length(gBuffer) >= $CONTENT_LENGTH
>     read from stdin until empty
>     put it after gBuffer
>   END REPEAT
>   put "cmd=_notify-validate&" & gBuffer into vReturn
>
>   post vReturn to "http://www.sandbox.paypal.com/cgi-bin/webscr "
>  --After this post, the "it" variable is empty, and so is the result
>



More information about the use-livecode mailing list