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

curl-and-php

Re: PHP - CURL - Custom authentication script

From: David Colter <dolan2go_at_yahoo.com>
Date: Wed, 30 Mar 2011 20:45:02 -0400

Michael,

Do you have Live Headers for your firefox session?

> $headers[] = 'Connection: Keep-Alive';
> $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=ISO-8859-1';
> $headers[] = 'Expect:';

I see a few more things you could look at.

You might try a different set of $headers. For example, I see firefox sending the below:

$header_array[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$header_array[] = "Accept-Language: en-us,en;q=0.5";
$header_array[] = "Accept-Encoding: gzip,deflate";
$header_array[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header_array[] = "Keep-Alive: 115";
$header_array[] = "Connection: Keep-Alive";

These I use exactly as Live Headers show firefox sending. Also, I don't think you need to declare the second on (your) above. curl will add that to the POST request (my experience).

It might help to have this set, just in case the server's checking for robots.
curl_setopt ( $ch1, CURLOPT_USERAGENT, $WEBBOT_NAME ); // Desire User agent string (copy firefox or IE)

I did a test on the url you provided. The referer is changing from page to page or not even present.

On many occasions, I print out the Live Header content, the verbose output, and modify the script until they MATCH. Based on what I see, you are not matching the browser's request, and therefore the server is sending something you don't want. That's the point of the exercise with verbose output and Live Headers.

> The POST string pulled from LiveHeaders works perfectly when pasted into my code, however when I replace the SUPER LONG variable (with the current one extracted from HTML) I get a system permission error.
>
> Are you encoding the string correctly?

The POST string must also MATCH.

Unless you try to match the (entire) output of curl with the browser's request headers and then compare response headers, it might take a very long time to complete this. You might also want to reread my first (or second) reply with regard to curl and followlocation.

Best regards,

David
 

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2011-03-31