时间:2022-04-12加入收藏
<?php
function httpGET($target_url, $get_data = array()){
$result = @file_get_content($target_url.'/?'.http_build_query($get_data));
return $result;
}
/*
* 方法2
*/
function httpGET2($target_url, $get_data = array()){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $target_url.'/?'.http_build_query($get_data));
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
?>
<?php
function httpPOST($url , $post_data = array()){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
?>