使用到的函数是curl_init, curl_setopt, curl_exec,curl_close。

默认是GET方法,可以选择是否使用Header:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_HEADER, 1); //如果设为0,则不使用header
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
curl_close($ch);

POST方法:

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'$url');
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
$vars =sprintf('from=%d&to=%d&subject=%s&body=%s',$from, $to, urlencode($subject), urlencode($body));
curl_setopt($ch,CURLOPT_POSTFIELDS,$vars);
$ret = curl_exec($ch);
curl_close($ch);
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com