-
-
//curl post example
- $url = 'http://bbs.it-home.org';
- $param1 = "param1";//参数1
- $param2 = "param2";//参数2
- $param3 = "param3";//参数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);
$response = curl_exec( $ch );
- echo 'response = '.$response."";
- ?>
-
复制代码
以上代码比较简单,主要用来熟悉下curl的post用法,仅供初学的朋友参考。
程序员之家,祝大家学习进步。
|