Forum Moderators: coopster

Message Too Old, No Replies

php/curl? I don't get it

no-cache?!

         

dexter001

9:36 pm on Feb 16, 2007 (gmt 0)

10+ Year Member



( I replaced the username and password ... but even this way I should get an error message .. )

HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Fri, 16 Feb 2007 21:31:14 GMT Server: Apache P3P: CP="NON DSP COR DEVa PSAa OUR BUS UNI COM" policyref="http://mydomain.myx.net/w3c/p3p.xml" Set-Cookie: tracking_id=b496716b2b21be8a249def2c59e2da72; expires=Wednesday, 15-Feb-12 21:31:14 GMT; path=/; domain=.myx.net Set-Cookie: adu=68305b8c56ac0c1e7e3587be251fbf5d; path=/; domain=.myx.net Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Transfer-Encoding: chunked Content-Type: text/html

I don't get it .. it doesn't log me in! .. what's wrong?!

[root@macro-net curl]# cat curl.php
<?

$reffer = "http://mydomain.myx.net/login/index.html";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";

$header_array[0] = "GET /secure/2_application.asp HTTP/1.1";
$header_array[1] = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9" ;
$header_array[2] = "Host: www.picturetheloan.co.uk";
$header_array[3] = "Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header_array[4] = "Accept-Language: en-us,en;q=0.5";
$header_array[5] = "Accept-Encoding: gzip,deflate";
$header_array[6] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header_array[7] = "Keep-Alive: 300";
$header_array[8] = "Connection: Close";

$postfields = array();
$postfields['domain'] = "hdc1977";
$postfields['domain_type'] = "net";
$postfields['password'] = "blahblah";

$url = "http://mydomain.myx.net/login/";
$cookie_file_path = "/usr/local/apache2/htdocs/macro-net.ro/secure/curl/cookie.txt";

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header_array);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt ($ch, CURLOPT_COOKIE, session_name().'='.session_id() );
curl_setopt ($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt ($ch, CURLOPT_REFERER, $reffer);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header_array);
curl_setopt ($ch, CURLOPT_USERAGENT, $agent);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_VERBOSE, 1);
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);

echo $content;
?>

eelixduppy

3:18 pm on Feb 18, 2007 (gmt 0)



Welcome to WebmasterWorld, dexter001!


but even this way I should get an error message

What is the error message you are receiving?

mcavic

7:13 pm on Feb 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You seem to be trying to send POST data, but you're sending a GET request? And you probably don't need to set all of those headers manually.