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

curl-and-php

Re: Problems using cUrl

From: Laurie Barker <laurie_at_oneuponedown.co.uk>
Date: Wed, 13 Aug 2003 15:42:30 +0100

On 13/08/2003 15:09 you wrote:
> I´m trying to use cUrl to get contents from a web page from a secure server
> and use it, but I can´t do it!
> I´m using a Linux server, Php 4.2.3, cUrl 7.10.6 and OpenSSL 0.9.7b. When I
> execute the script, I receive a blank page as a return. Could anyone help me?
> That´s the code:
>
> $url = "https://www.server.com/folder/Page.jsp";
> $ch = curl_init(); // initialize curl handle
> curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
> curl_setopt($ch, CURLOPT_FAILONERROR, 1);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
> curl_setopt ($ch, CURLOPT_REFERER, "https://www.myserver.com/folder/");
> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
> curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
> curl_setopt($ch, CURLOPT_POST, 1); // set POST method
> curl_setopt($ch, CURLOPT_POSTFIELDS,
> "var1=value1&var2=value2&var3=value3&var4=value4"); // add POST fields
> $result = curl_exec($ch); // run the whole process
> curl_close($ch);
> echo $result;

Probably a good idea to check for an error in the connection using
"curl_errno" and "curl_error". A failurer routine is a must when
communicating with other servers in this method as the internet is not a
fault free enviroment.

I would also suggest that a time-out of 3/4's is probably a little
optimistic, expecially when using https. Try 30 seconds.

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-08-13