session - php curl post data to get value form referred url -


i want send post data page value. problem want data form abc.com. , abc.com opens if user comes abc.com abc.com/previous url.

maybe is doing session or cookies authenticate. have no idea.

what want data abc.com. there way via curl it?

my php code:

when run code says url has moved url need come old refer url works in browser

$searchby = "2"; $attorneysearchmode="name"; $lastname= "smith"; $firstname= "william"; $casestatustype= "0"; $sortby= "fileddate";   echo $url = 'https://www.clarkcountycourts.us/anonymous/search.aspx?id=400&nodeid=101%2c103%2c104%2c105%2c500%2c600%2c601%2c602%2c603%2c604%2c605%2c606%2c607%2c608%2c609%2c610%2c611%2c612%2c613%2c614%2c615%2c616%2c617%2c618%2c619%2c699%2c700%2c701%2c702%2c703%2c704%2c705%2c706%2c707%2c708%2c709%2c710%2c711%2c712%2c713%2c714%2c715%2c716%2c717%2c718%2c719%2c720%2c721%2c722%2c723%2c724%2c725%2c726%2c727%2c728%2c729%2c730%2c731%2c797%2c798&nodedesc=all+courts';  //set post variables $fields = array(     'searchby' => urlencode($searchby),     'attorneysearchmode' => urlencode($attorneysearchmode),     'lastname' => urlencode($lastname),     'firstname' => urlencode($firstname),     'casestatustype' => urlencode($casestatustype),     'sortby' => urlencode($sortby), ); $fields_string = ""; foreach ($fields $key=>$value) {     $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); $ch = curl_init();  curl_setopt($ch,curlopt_url, $url); curl_setopt($ch,curlopt_post, true); curl_setopt($ch,curlopt_post, count($fields)); curl_setopt($ch,curlopt_postfields, $fields_string);  $result = curl_exec($ch); curl_close($ch); print_r($result); 

here starting point minor additions.

i found 3 issues prevented me requesting page on server:

  1. need enable cookies in curl , fetch 1 page before posting
  2. needed disable ssl checks (curlopt_ssl_verifypeer, curlopt_ssl_verifyhost)
  3. some necessary form fields missing request

in example below first fetch main search page, , re-use same curl handle post form. note incomplete, need write code populate remaining form fields.

// first fetch search page set cookies $url = 'https://www.clarkcountycourts.us/anonymous/search.aspx?id=400&nodeid=101%2c103%2c104%2c105%2c500%2c600%2c601%2c602%2c603%2c604%2c605%2c606%2c607%2c608%2c609%2c610%2c611%2c612%2c613%2c614%2c615%2c616%2c617%2c618%2c619%2c699%2c700%2c701%2c702%2c703%2c704%2c705%2c706%2c707%2c708%2c709%2c710%2c711%2c712%2c713%2c714%2c715%2c716%2c717%2c718%2c719%2c720%2c721%2c722%2c723%2c724%2c725%2c726%2c727%2c728%2c729%2c730%2c731%2c797%2c798&nodedesc=all+courts';  $ch = curl_init();  // needed disable ssl checks site curl_setopt($ch,curlopt_ssl_verifyhost,0); curl_setopt($ch,curlopt_ssl_verifypeer,0);  // enable cookie handling (they aren't saved after curl closed) curl_setopt($ch,curlopt_cookiefile, '');  // debugging curl_setopt($ch,curlopt_verbose, 1); curl_setopt($ch,curlopt_stderr, fopen('php://output', 'w'));  // helpful options curl_setopt($ch,curlopt_autoreferer, true); curl_setopt($ch,curlopt_returntransfer, true); curl_setopt($ch,curlopt_followlocation,1);  // set first url curl_setopt($ch,curlopt_url, $url);  // execute first request establish cookies & referer     $data = curl_exec($ch);  // todo: extract hidden form fields/values form  $fields_string = '...';  // make second request curl_setopt($ch,curlopt_post, true); curl_setopt($ch,curlopt_postfields, $fields_string);  $result = curl_exec($ch); curl_close($ch); var_dump($result); 

see of other answers linked here shows how extract other form fields , multiple requests. see (curl -- cookies , sessions) , (php curl - cookies problem)

hope helps, comment issues/questions.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -