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

curl-and-php

PHP - CURL - Custom authentication script

From: Michael Gawrychowski <mgawrych_at_excelmicro.com>
Date: Tue, 29 Mar 2011 08:51:32 -0400

I'm trying to create a script (PHP + cURL) that will go to a website, log
in, navigate to a sub page, fill out a specific form and submit. I was able
to log in and navigate to the form, however when I try to submit any data to
the file specified in the form I get a blank screen so it seems like it
rejects the data. I checked all cookies generated by cURL and I compared
them to cookies created by Firefox (Firebug extension for cookies). They all
look the same. I also double checked all of the $_POST variables. They all
look correct.

I got to the point where I figured that it must be JavaScript code that
creates some variables / cookies on the fly but they don't show up anywhere.
However when I try to submit the form with Firefox and JavaScript turned
off I get the blank screen too.

Any ideas? The variable "com.salesforce.visualforceViewState" is very long.
Can it cause the problem?
.

preg_match("[com.salesforce.visualforce.ViewState\" value=\"(.*)\"
]U", $content3, $result);

preg_match("[com.salesforce.visualforce.ViewStateMAC\" value=\"(.*)\"
]U", $content3, $result1);
preg_match("[com.salesforce.visualforce.ViewStateCSRF\" value=\"(.*)\"
]U", $content3, $result2);

$posts = "j_id0:j_id6:info:j_id16:secAsset:asset=02i600000049V3g&j_id0:j_id6:info:j_id16:secProductLine:or-data=&j_id0:j_id6:info:j_id16:secGroup:group=Tech
Support&j_id0:j_id6:info:j_id16:secFunction:function=a0T60000000IGGZEA4&j_id0:j_id6:info:j_id16:secSubFunction:subfunction=a0e60000000j0W9AAI&j_id0:j_id6:info:j_id16:secLanguage:language=English&j_id0:j_id6:info:j_id16:secPriority:priority=P4
- Low Impact&j_id0:j_id6:details:Apps:secCountry:country=US&j_id0:j_id6:details:Apps:secCPINApps:cpinapps&j_id0:j_id6:details:Desc:secSubject:subject=TEST&j_id0:j_id6:details:Desc:secDescription:description=Please
disregard this message&j_id0:j_id6:details:Desc:secReproduce:reproduce=&j_id0:j_id6:info:j_id16:secProductLine:or-data=Create
New Case&com.salesforce.visualforce.ViewState=".$result[1]."&com.salesforce.visualforce.ViewStateMAC=".$result1[1]."&com.salesforce.visualforce.ViewStateCSRF=".$result2[1]."&j_id0:j_id6:details:j_id59:j_id60=Create
New Case";

curl_setopt($ch, CURLOPT_URL, "https://c.na4.visual.force.com/apex/NewCase");
curl_setopt($ch,CURLOPT_REFERER,urlencode("https://c.na4.visual.force.com/apex/NewCase?retURL=%2F500%2Fo&save_new=1&sfdc.override=1"));

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $posts);
$content4 = curl_exec ($ch);
echo $content4;

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