返回顶部

收藏

curl post方式访问网页

更多
$url = http://xxxx.com;

$params = array('id'=>11,'aa'=>22,'cc'=>33);

$data = http_build_query($params);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if('' != $data){
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}

curl_setopt($ch, CURLOPT_TIMEOUT, 6);
$result = curl_exec($ch);
var_dump(curl_error($ch));
curl_close($ch);
return $result;

标签:php

收藏

0人收藏

支持

0

反对

0

发表评论