By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

cURL post data to asp.net page

P: 1
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.HttpUnhandledException' was thrown.
Expand|Select|Wrap|Line Numbers
  1. $url = "http://opanet.hrsa.gov/OPA/Reports/Reports.aspx";
  2. $params = array(
  3.     'aspnetForm' => '',
  4.     '__EVENTTARGET' => 'ctl00$cphMainContent$tvReports',
  5.     '__EVENTARGUMENT' => 'sDaily Reports Menu\\Real-time Reports\\CE Real-time Report'
  6. );
  7.  
  8.  
  9. $ch = curl_init();
  10.  
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 900);
  13. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)");
  14.  
  15. curl_setopt($ch, CURLOPT_HEADER, 0);
  16. curl_setopt($ch, CURLOPT_POST, 1);
  17.  
  18. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  19. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  20. curl_setopt($ch, CURLOPT_AUTOREFERER, true );
  21.  
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
  23. curl_setopt($ch, CURLOPT_FAILONERROR, 0);
  24.  
  25. curl_exec($ch);
  26.  
  27. curl_close($ch);
  28.  
Dec 18 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.