cURL / Mailing Lists / curl-users / Single Mail

curl-users

curl not working on server

From: James Ramroop <rramroop_at_gmail.com>
Date: Thu, 11 Jun 2009 08:14:08 +0100

Hello,
I have a php script that's using curl to post login data to a website.
When I test the script on my local WAMP server it works absolutely fine but
it does not work on my VPS
On both servers local and VPS I have php 5 and
localhost - libcurl/7.16.0 OpenSSL/0.9.8e zlib/1.2.3 installed
VPS - libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5

The code is as follows

--------------- PHP ----------------------------------------------------
$url = "http://www.affilipoint.com/manager/login";

$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_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 60); // times out after 4s
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0;
Windows NT 6.0)");
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS,
"username=rramroop_at_gmail.com&password=*********");
// add POST fields
$result = curl_exec($ch); // run the whole process

print_r(curl_getinfo($ch));
echo "\n\ncURL error number:" .curl_errno($ch);
echo "\n\ncURL error:" . curl_error($ch);
// ...close cURL handle ($ch) below

curl_close($ch);
echo $result;
---------------------------------------------------------------------------

-------------------- LOCALHOST RESULT -------------------
Array
(
    [url] => http://www.affilipoint.com/manager/dashboard
    [content_type] => text/html
    [http_code] => 200
    [header_size] => 4886
    [request_size] => 1096
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 1
    [total_time] => 1.59
    [namelookup_time] => 0
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 2531
    [speed_download] => 1591
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 0.484
    [redirect_time] => 1.106
)

cURL error number:0

cURL error:

echos the page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
-------------------- LOCALHOST RESULT -------------------

--------------------- VPS RESULT ------------------------------
Array
(
    [url] => http://www.affilipoint.com/manager/login
    [content_type] => text/html
    [http_code] => 302
    [header_size] => 4706
    [request_size] => 250
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.199998
    [namelookup_time] => 0.007487
    [connect_time] => 0.012401
    [pretransfer_time] => 0.012449
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 0.199946
    [redirect_time] => 0
)

cURL error number:0

cURL error:

1
--------------------- VPS RESULT ------------------------------

Any ideas what could be the problem and how to fix it. Correct me if I am
wrong but I believe this is a configuration problem on my server?

Many thanks

James

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-06-11