Topic awaiting preservation: fetching a form that requires POST using FPUTS |
|
---|---|
Author | Thread |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 06-02-2006 23:15
Greets! |
Maniac (V) Inmate From: Sthlm, Sweden |
posted 06-03-2006 00:22
Never used fputs for stuff like this, however, we do pass simulated form data through post to remote servers all the time at work. |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 06-03-2006 11:19
yeah, curl is the easier way to go. code: function makeFunnyPost ( $strPath, $strHostName, $arrData ) { $strPostData = ''; foreach ( $arrData as $strKey => $strValue ) { if ($strPostData) $strPostData .= '&'; $strPostData .= urlencode ( $strKey ) . '='. urlencode ( $strValue); } $strRequest = "POST ". $strPath. " HTTP/1.0\r\n". "Host: ". $strHostName . "\r\n". "Content-Type: application/x-www-form-urlencoded\r\n". "Content-length: ". strlen($strPostData). "\r\n". "\r\n". $strPostData. "\r\n"; $fh = fsockopen($strHostName,80); if ($fh) { fwrite($fh,$strRequest); $strResponse = ''; while (!feof($fh)) { $strResponse .= fread($fh,2048); } fclose($fh); $strResponse = trim(substr($strResponse,strpos($strResponse,"\r\n\r\n"))); //cut of http header. return $strResponse; } else return False; }
|
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 06-22-2006 04:53
Alright - I'm not having much luck with this. |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 06-22-2006 07:15
Case Sensitive Option Values. code: <?php $url="http://www.state.mi.us/mdoc/asp/otis2results.asp"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, 1); $strPostFields = "last=Kevorkian&first=Jack&gender=Either&race=All&status=All"; curl_setopt ($ch, CURLOPT_POSTFIELDS, $strPostFields ); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec ($ch); curl_close ($ch); echo $content; ?> |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 06-22-2006 14:09 |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 06-22-2006 17:10
Try setting some browser like headers... I'd start with User-Agent |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 06-22-2006 17:56 |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 06-22-2006 21:16
In that case, it could easily be the name lookup for the host. |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 06-23-2006 02:59 |