Example of simulating a post request using phpcurl. 1. local machine: $ uriwww. jbxue. comtest. php; replace it with the address parameter array of your server $ dataarray (nametantengpasswordpassword)
1. local machine:
$ Uri = "http://www.jbxue.com/test.php"; // address of your server here
// Parameter array
$ Data = array (
'Name' => 'tanteng'
// 'Password' => 'password'
);
$ Ch = curl_init ();
// Print_r ($ ch );
Curl_setopt ($ ch, CURLOPT_URL, $ uri );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data );
$ Return = curl_exec ($ ch );
Curl_close ($ ch );
Print_r ($ return );
2. remote server:
If (isset ($ _ POST ['name']) {
If (! Empty ($ _ POST ['name']) {
Echo 'hello, ', $ _ POST ['name'].'! ';
}
}
Optional $ uri = "http://www.jbxue.com/test.php "; // replace this with the address of your server. // The parameter array $ data = array ('name' = 'tanteng' // 'password' = 'password ')...