标签:http os io ar cti sp on c amp
/** * CURL请求 * @param $url * @param array Con * @param String POST,XML,GET * * @return Array | String | XML */ protected function http_get_contents($url, $con = array(), $type = ‘GET‘) { $ch = curl_init(); $timeout = 15; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_ENCODING, "gzip" ); if($type == "POST" && !empty($con)) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $con); } if($type == "XML" && !empty($con)) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $con); 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; }
标签:http os io ar cti sp on c amp
原文地址:http://my.oschina.net/onlyou/blog/311773