php - cURL and ASP.NET : issue with post parameters -


We have a search engine, which was programmed in asp.net. I manage curl personal results because they have more or less direct links which I can guess and curl. But I do not manage to get the result list desired, here's how it works:

On the search page we have to select a database that we want to search through the checkbox menu. Once I want to find DB, I click on the "Search" button which takes me to the search page and selects DB while keeping in mind.

If I try to go straight to the search page link, it does not work because it does not know which DB will be searched. I tried to see the post parameters with the firebug and I found the following:

  checkbox_db 1___ventory_generation_aventet linkbutton senate __viewSTATE zeyhbf5vg41g6a4f1ezragf136er46ga4gfv658a4r6g4 (something looks like now but now)  < / Pre> 

What I try to curl is:

  $ ch = curl_init (); $ Fields = array ( 'Checkbox_db1' = & gt; 'on', '__EVENTARGUMENT' = & gt; '', '__EVENTTARGET' = & gt; 'Linkbtn category', '__VIEWSTATE' = & gt; ''); $ Postvars = ''; Forex currency ($ field as $ key = & gt; $ value) {$ postvars = $ Key '='. $ Value '& Amp;'; } Rtrim ($ postvars, '& amp;'); Curl_setopt ($ CH, CURLOPT_URL, "monsite.com/choosedb.aspx"); Curl_setopt ($ CH, CURLOPT_POST, Count ($ fields)); Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postvars); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); $ Output1 = curl_exec ($ ch); $ Fields2 = Array ( "Tkstboksl '= & gt;' VALUE1 'Tkstboks2' = & gt; 'value2', '__awantrjument' = & gt; '' __aventtrget '= & gt;' '__vavstte' = & Gt; ''); $ Postvars = ''; Forex Currency ($ fields2 $ key = & gt; $ value) {$ postvars = $ Key '='. $ Value '& Amp;'; } Rtrim ($ postvars, '& amp;'); Curl_setopt ($ CH, CURLOPT_URL, "monsite.com/search.aspx"); Curl_setopt ($ CH, CURLOPT_POST, calculation ($ fields2)); Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postvars); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); $ Output2 = curl_xac ($ CH);  

But of course this does not work ... and this issue is that I am not familiar with ASP.NET / can anybody help? Thank you in advance

Firstly, you get curl on the initial page regularly.

then you must remove VIEWSTATE parameters:

  $ regexViewstate = '/ __ Vistat \ "value = \" (. *) \ "/ I'; function regexExtract ( $ text, $ Regex, $ regs, $ nthValue) {if (preg_match ($ regex, $ text, $ regs)) {$ result = $ regs [$ nthValue];} and {$ result = "";} return $ Result;} $  

and you create your new post:

  $ postData = '__EVENTARGUMENT = & Amp; __EventTarGET = LinkButtonCategory & amp; __ViewSTATE = '; $ postData. = Rawurlencode ($ view). & Amp; TxtBox1 = value1 and TxtBox2 = value2'; curl_setOpt ($ ch, CURLOPT_POST, TRUE); curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ PostData); curl_setopt ($ ch , CURLOPT_URL, $ urllogin); curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookieFile); $ output = Krl_akssi ($ ch);  
< / Div>

Comments