cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: cURL result into variable

From: Pete James <peter_james_at_advanis.ca>
Date: Tue, 23 Apr 2002 12:35:27 -0600

Use the CURLOPT_RETURNTRANSFER option, and you will get the result in
the $result variable.
 
function achPost($MEN,$MPA,$MID,$CRO,$CAC,$CPH,$PAM)
{
    $URL="onlinechecks.interceptcorporation.com/icolc/short.cgi";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"https://$URL");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS,
"MEN=$MEN&MPA=$MPA&MID=$MID&CRO=$CRO&CAC=$CAC&CPH=$CPH&PAM=$PAM");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        curl_close ($ch);
        return $result;
}

Adrian Mcmanus wrote:
>
> Hello,
>
> I am new to cURL and I am attempting to post to a secure server using CURL.
> I am able to post my variables to the server just fine and return the result
> onto the page but I can not seem to return the result into a variable so
> that I am parse the result string.
>
> Here is my code:
>
> function achPost($MEN,$MPA,$MID,$CRO,$CAC,$CPH,$PAM)
> {
> $URL="onlinechecks.interceptcorporation.com/icolc/short.cgi";
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL,"https://$URL");
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS,
> "MEN=$MEN&MPA=$MPA&MID=$MID&CRO=$CRO&CAC=$CAC&CPH=$CPH&PAM=$PAM");
> $result = curl_exec($ch);
> curl_close ($ch);
> return $result;
> }
>
> The result is returning a value of 1. Any help would be greatly
> appreciated.
>
> Regards,
>
> Adrian Mcmanus
> adrianm_at_airmail.net

Received on 2002-04-23