TLingC's Zone
PHP curl post/get数据函数

Post

function postData($url, $data)
{
$ch = curl_init();
$timeout = 300;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, ""); //来路
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$handles = curl_exec($ch);
curl_close($ch);
return $handles;
}

Get

function getData($url)
{
$ch = curl_init();
$timeout = 300;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$handles = curl_exec($ch);
curl_close($ch);
return $handles;
}
赞赏
首页      开发      PHP curl post/get数据函数

发表评论

textsms
account_circle
email

TLingC's Zone

PHP curl post/get数据函数
Post function postData($url, $data) { $ch = curl_init(); $timeout = 300; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, ""); //来路 curl_setopt($ch, …
扫描二维码继续阅读
2017-06-21
标签
功能