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

curl-and-php

redirect don't work ?

From: Роман Ковальский <steel_d_at_mail.ru>
Date: Sat, 26 May 2012 00:25:45 +0400

С уважением, Роман Ковальский Hi! I am from Ukraine :)

So I have this code and a question:

// CODE ---------------------------------------------------------------
 $login_value = $_GET["login_value"];
 $password_value = $_GET["password_value"];

 $postdata = array(
 'login[email]' => $login_value,
 'login[password]' => $password_value
 );

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://slando.ua/account/?ref%5B0%5D%5Baction%5D=user&ref%5B0%5D%5Bmethod%5D=index");

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1");

 $headers = array
 (
 'Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, * /*;q=0.1',
 'Accept-Language: ru-RU,ru;q=0.9,en;q=0.8',
 'Accept-Encoding: deflate',
 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7',
 'Expect:'
 );

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_ENCODING, "");

 curl_setopt($ch, CURLOPT_REFERER, "http://slando.ua/account/?ref%5B0%5D%5Baction%5D=user&ref%5B0%5D%5Bmethod%5D=index");

$cookie_file_path = create_tmp_cookie($user_prm["sp_login"], "libcurl");
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
 curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$out = curl_exec($ch);

 echo "\n\ncURL error number:" . curl_errno($ch) . " <br/>";
 echo "\n\ncURL error:" . curl_error($ch) . " <br/>";
 print_r(curl_getinfo($ch));

when i do this at my local (home) webserver - all ok!
i get this:

// LOCAL RESULT -----------------------------------------------
cURL error number:0 <br/>

cURL error: <br/>Array
(
 [url] => http://slando.ua/my/
 [content_type] => text/html
 [http_code] => 200
 [header_size] => 748
 [request_size] => 1352
 [filetime] => -1
 [ssl_verify_result] => 0
 [redirect_count] => 1
 [total_time] => 0.312
 [namelookup_time] => 0
 [connect_time] => 0
 [pretransfer_time] => 0
 [size_upload] => 274
 [size_download] => 29996
 [speed_download] => 96141
 [speed_upload] => 878
 [download_content_length] => 0
 [upload_content_length] => 0
 [starttransfer_time] => 0.125
 [redirect_time] => 0.078
 [certinfo] => Array
 (
 )

)
//---------------------------------------------------------
 but if i use same code at the hosting - redirect don't work!
// HOSTING RESULT ---------------------------------------

cURL error number:0 <br/>

cURL error: <br/>Array
(
 [url] => http://slando.ua/account/?ref%5B0%5D%5Baction%5D=user&ref%5B0%5D%5Bmethod%5D=index
 [content_type] => text/html
 [http_code] => 301
 [header_size] => 326
 [request_size] => 685
 [filetime] => -1
 [ssl_verify_result] => 0
 [redirect_count] => 0
 [total_time] => 0.226617
 [namelookup_time] => 1.5E-5
 [connect_time] => 0.03563
 [pretransfer_time] => 0.035677
 [size_upload] => 274
 [size_download] => 0
 [speed_download] => 0
 [speed_upload] => 1209
 [download_content_length] => 0
 [upload_content_length] => 274
 [starttransfer_time] => 0.035679
 [redirect_time] => 0
)

what is the problem ?
Thank you for help!

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2012-05-25