cURL problem

I have a website that I am trying to use Curl with and no matter what I try, the page does NOT recognize the POST fields. The website was originally done by someone else. I have gone through the code and don’t see anything that could do this?

I tried pointing the Curl POST code to another server and it all works. So my belief is there must be something blocking the curl request.

I set cookies in the curl script.

I have tried using several diferent user agents and tried using “1” instead of “true”. The results are always the same.

I have tried posting the fields as an array and as a concatenated string - no change.

I am just trying anything that could make sense to work. I have tried browser user agents (mozilla, netscape, etc…) and nothing.

I tried removing all the cURL options except the POST stuff and URL. Still won’t work.

I get no post field results. It is as if the POST never happened.

Is there code that can block this type of POST that I need to look for in this website or server configuration?


My code looks like this
$target_url = $webs[‘website_url’];
$userAgent = ‘IMPostFields’;
$fields = array();
$fields_string = “”;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
foreach($fields as $key=>$value) { $fields_string .= $key.’=’.$value.’&’; }
$fields_string = rtrim($fields_string,’&’);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HEADER ,false );
curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
curl_setopt($ch, CURLOPT_COOKIEJAR, ‘cookie.txt’);
curl_setopt($ch, CURLOPT_COOKIEFILE, ‘cookie.txt’);
$html= curl_exec($ch);

Sponsor our Newsletter | Privacy Policy | Terms of Service