cURL post data to asp.net page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kabir khan
    New Member
    • Dec 2011
    • 1

    cURL post data to asp.net page

    I am trying to call the __doPostback javascript function in a asp.net page from php using curl.
    I used below code but getting error like
    Encountered error while processing the request. Please try again using the Home button.

    Diagnostic Information:
    Error Type: Exception of type 'System.Web.Htt pUnhandledExcep tion' was thrown.
    Code:
    $url = "http://opanet.hrsa.gov/OPA/Reports/Reports.aspx";
    $params = array(
    	'aspnetForm' => '',
        '__EVENTTARGET' => 'ctl00$cphMainContent$tvReports',
        '__EVENTARGUMENT' => 'sDaily Reports Menu\\Real-time Reports\\CE Real-time Report'
    );
    
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 900);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)");
    
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true );
    
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
    curl_setopt($ch, CURLOPT_FAILONERROR, 0);
    
    curl_exec($ch);
    			
    curl_close($ch);
Working...