Use PHP to simulate POST to submit data. Use php socket programming to directly send data to the interface to simulate post operations .? **************************************** * ******************* Name: POST test program Vesion: 1.0 uses php socket programming to directly send data to the interface to simulate post operations.
<?
/*************************************** ********************
Name: POST test program Vesion: 1.0 Date: *************************************** *********************/
/$ Flag = 0;
// Data to be post
$ Argv = array (
'Var1' => 'ABC ',
'Var2' => '');
// Construct the string to post
Foreach ($ argv as $ key => $ value ){
If ($ flag! = 0 ){
$ Params. = "&";
$ Flag = 1;
}
$ Params. = $ key. "="; $ params. = urlencode ($ value );
$ Flag = 1;
}
$ Length = strlen ($ params );
// Create a socket connection
$ Fp = fsockopen ("127.0.0.1", 80, $ errno, $ errstr, 10) or exit ($ errstr. "--->". $ errno );
// Construct the post request header
$ Header = "POST/mobile/try. php HTTP/1.1rn ";
$ Header. = "Host: 127.0.0.1rn ";
$ Header. = "Referer:/mobile/sendpost. phprn ";
$ Header. = "Content-Type: application/x-www-form-urlencodedrn ";
$ Header. = "Content-Length:". $ length. "rn ";
$ Header. = "Connection: Closernrn ";
// Add the post string
$ Header. = $ params. "rn ";
// Send post data
Fputs ($ fp, $ header );
$ Inheader = 1;
While (! Feof ($ fp )){
$ Line = fgets ($ fp, 1024); // only the returned data on the page is displayed when the request packet header is removed.
If ($ inheader & ($ line = "n" | $ line = "rn ")){
$ Inheader = 0;
}
If ($ inheader = 0 ){
Echo $ line;
}
}
Fclose ($ fp );
?>
Bytes. ? /*************************************** * ******************** Name: POST test program Vesion: 1. 0...