Advertisement

10.12.2008 at 04:02PM PDT, ID: 23808190 | Points: 500
[x]
Attachment Details

ASP CURL and PHP - Post to an ASP site from PHP

Asked by michel-angelo in Programming for ASP.NET, Active Server Pages (ASP), PHP Scripting Language

Tags:

I do not know anything about .net or sp in general.
I aam hoping somebody familiar with PHP and Curl library could tell me how I could post to a .net site.
The _viewstate, the _eventvalidation are a bit obscur.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
<?php
 
$url="https://elicensing.iowaabd.com/OnDemandReport.aspx";
 
$referer="https://elicensing.iowaabd.com";
$header[] = "Content-type: text/html";
$cookie="cookie.txt";
$fp=fopen($cookie,w);
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_REFERER,$referer);
curl_setopt($ch, CURLOPT_TIMEOUT, 900);
curl_setopt($ch, CURLOPT_CONNECTIONTIMEOUT, 30);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
 
$content=curl_exec($ch);
 
 
$array=explode("\n",$content);
$count=count($array);
for($i=0;$i<$count;$i++){
if(stristr($array[$i],"__VIEWSTATE")){
$array1=explode('value="',$array[$i]);
$content1=$array1[1];
$array2=explode('"',$content1);
$content2=$array2[0];
$_VIEWSTATE=$content2;
}
if(stristr($array[$i],"__EVENTVALIDATION")){
$array1=explode('value="',$array[$i]);
$content1=$array1[1];
$array2=explode('"',$content1);
$content2=$array2[0];
$_EVENTVALIDATION=$content2;
}
}
 
 
 
 
$url="https://elicensing.iowaabd.com/OnDemandReport.aspx";
 
 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$content_stage2=curl_exec($ch);
 
 
 
?>
 
Loading Advertisement...
 
[+][-]10.12.2008 at 09:50PM PDT, ID: 22700230

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.18.2008 at 07:33PM PST, ID: 22991294

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628