php中curl post方式的小例子,如下:
<?php
//curl post example
$url = 'http://www.jb200.com';
$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用法,仅供初学的朋友参考。
脚本学堂,祝大家学习进步。