cURL Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D Benfer

    cURL Question


    Hi all,

    Im a bit thrown by curl. I want to submit some order data on an ecommerce
    site via a form to a php page, where the data is saved to a database.
    Then I want to use curl to submit the form data I just saved (and
    redirect the user) to my secure credit card gateway.

    Problem is, they have their own secure payment screen where the credit
    card information is entered. I can't just retrieve the variable with a
    transaction success/failure setting. Plus, the curl code I use sends me
    there as if I was still on my own server. No secure connection, and the
    graphics on their server tries to load from mine. Looks very poor.

    Anyway, here's the code:

    $ch = curl_init("http s://server.com/payment.url");
    curl_setopt($ch , CURLOPT_HEADER, 0);
    curl_setopt($ch , CURLOPT_POST, 1);
    curl_setopt($ch , CURLOPT_POSTFIE LDS, $postdata);
    curl_setopt($ch , CURLOPT_FOLLOWL OCATION, 1);
    curl_setopt($ch , CURLOPT_REFERER , "http://site.com/payment.html");
    curl_setopt($ch , CURLOPT_RETURNT RANSFER, 0);
    curl_exec($ch);
    curl_close($ch) ;


    I guess my question is - is there an option in curl to acutally get the
    browser to follow the posted data as if I clicked the button on a page?
    FOLLOWLOCATION does not get me there for some reason.

    All help is greatly appreciated!

    DB
  • D Benfer

    #2
    Re: cURL Question

    Louis-Philippe Huberdeau <lphuberdeau@sy mpatico.ca> wrote in
    news:cDXTa.7043 $1I5.869622@new s20.bellglobal. com:
    [color=blue][color=green]
    >> D Benfer wrote:
    >> Hi all,
    >>
    >> Im a bit thrown by curl. I want to submit some order data on an
    >> ecommerce site via a form to a php page, where the data is saved to a
    >> database. Then I want to use curl to submit the form data I just
    >> saved (and redirect the user) to my secure credit card gateway.
    >>
    >> Problem is, they have their own secure payment screen where the
    >> credit card information is entered. I can't just retrieve the
    >> variable with a transaction success/failure setting. Plus, the curl
    >> code I use sends me there as if I was still on my own server. No
    >> secure connection, and the graphics on their server tries to load
    >> from mine. Looks very poor.
    >>
    >> Anyway, here's the code:
    >>
    >> $ch = curl_init("http s://server.com/payment.url");
    >> curl_setopt($ch , CURLOPT_HEADER, 0);
    >> curl_setopt($ch , CURLOPT_POST, 1);
    >> curl_setopt($ch , CURLOPT_POSTFIE LDS, $postdata);
    >> curl_setopt($ch , CURLOPT_FOLLOWL OCATION, 1);
    >> curl_setopt($ch , CURLOPT_REFERER , "http://site.com/payment.html");
    >> curl_setopt($ch , CURLOPT_RETURNT RANSFER, 0);
    >> curl_exec($ch);
    >> curl_close($ch) ;
    >>
    >>
    >> I guess my question is - is there an option in curl to acutally get
    >> the browser to follow the posted data as if I clicked the button on a
    >> page? FOLLOWLOCATION does not get me there for some reason.
    >>
    >> All help is greatly appreciated!
    >>
    >> DB
    >>[/color]
    >
    > Well, you just skipped the secure part anyway. From the HTML form to
    > your script which should redirect the connection, your connexion
    > wasn't secure, the data was not safe. cURL will handle the secure
    > connection from the script to the other form processor, but your
    > connection won't be secured by that.
    >
    > The best you can do is get the POST response by the secure server into
    > a string, analyse the result and display your own page. The default
    > behavior of cURL is to output the ressponse direcly, you can use
    > output buffering to solve that problem. (ob_start() and such).
    >[/color]

    Ah, ok. So the person who referred this to me was incorrect. I was told
    this would _redirect_ you to a page. It just fetches the resulting page,
    eh? No wonder I searched and searched and never found an answer! Thanks
    for the response!

    DB

    Comment

    Working...