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

curl-and-php

Re: PHP - CURL - Custom authentication script

From: Michael Gawrychowski <mgawrych_at_excelmicro.com>
Date: Wed, 30 Mar 2011 16:23:54 -0400

I guess so. This is my code below. This one and some others passes through
correctly: j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecPriority%3Apriority=P4+-+Low+Impact

The first I have problems with the following, and it looks exactly the same
like the one pulled from LIVE Headers...

j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecGroup%3Agroup=Tech+Support

Do you have any ideas? I'm almost ready to shoot myself...

MY CODE:

$content3 is the form page.

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%3Aj_id6=j_id0%3Aj_id6&j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecAsset%3Aasset=02i600000049V3g&j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecProductLine%3Aor-data=&j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecGroup%3Agroup=Tech+Support&j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecFunction%3Afunction=a0T60000000IGGZEA4&j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecSubFunction%3Asubfunction=a0e60000000JZItAAO&j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecLanguage%3Alanguage=English&j_id0%3Aj_id6%3Ainfo%3Aj_id16%3AsecPriority%3Apriority=P4+-+Low+Impact&j_id0%3Aj_id6%3Adetails%3AApps%3AsecCountry%3Acountry=US&j_id0%3Aj_id6%3Adetails%3AApps%3AsecCPINApps%3Acpinapps=&j_id0%3Aj_id6%3Adetails%3ADesc%3AsecSubject%3Asubject=&j_id0%3Aj_id6%3Adetails%3ADesc%3AsecDescription%3Adescription=&j_id0%3Aj_id6%3Adetails%3ADesc%3AsecReproduce%3Areproduce=&j_id0%3Aj_id6%3Adetails%3Aj_id59%3Aj_id60=Create+New+Case&com.salesforce.visualforce.ViewState=".urlencode($result[1])."&com.salesforce.visualforce.ViewStateMAC=".urlencode($result1[1])."&com.salesforce.visualforce.ViewStateCSRF=".urlencode($result2[1])."";
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type:
application/x-www-form-urlencoded;charset=ISO-8859-1';
$headers[] = 'Expect:';
curl_setopt($ch, CURLOPT_URL, "https://c.na4.visual.force.com/apex/NewCase
");
curl_setopt($ch, CURLOPT_REFERER,"
https://c.na4.visual.force.com/apex/NewCase");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $posts);
$verbose_file = 'xyz.txt';
$fp = fopen ( $verbose_file, 'w+' );
curl_setopt ( $ch, CURLOPT_VERBOSE, TRUE );
curl_setopt ( $ch, CURLOPT_STDERR, $fp );
fwrite ( $fp, "Post data sent: " . $posts . "\n\n" );
$content4 = curl_exec ($ch);
echo $content4;
print "<pre>\n";
print_r(curl_getinfo($ch)); // get error info
echo "\n\ncURL error number:" .curl_errno($ch); // print error info
echo "\n\ncURL error:" . curl_error($ch);
print "</pre>\n";
// $fp=fopen("result4.php","w");
// fwrite($fp,$content4);
// fclose($fp);
// echo "OK";

 }

On Wed, Mar 30, 2011 at 4:02 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Wed, 30 Mar 2011, Michael Gawrychowski wrote:
>
> 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?
>
> --
>
> / daniel.haxx.se
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>

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