-
-
//curl post example - $url = 'http://bbs.it-home.org';
- $param1 = "param1";//Parameter 1
- $param2 = "param2";//Parameter 2
- $param3 = "param3";//Parameter 3
$params = 'param1=' . $param1;
- $params = 'param2 =' . $param2;
- $params = 'param3=' . $param3;
$ch = curl_init( $url );
- curl_setopt( $ch, CURLOPT_POST, 1);
- curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params);
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt( $ch, CURLOPT_HEADER, 0);
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
- < ;p>$response = curl_exec( $ch );
- echo 'response = '.$response."";
- ?>
-
Copy code
The above code is relatively simple and is mainly used Let’s get familiar with curl’s post usage, for reference only for beginners.
Programmer's Home, I wish you all the best in your studies and progress.
|