/**
* 发送HTTP请求并获得响应
* @param url 请求的url地址
* @param param 发送的http参数
*/function makeRequest($url, $param, $httpMethod = 'GET') {<br>
$oCurl = curl_init();<br>
if (stripos($url, "https://") !== FALSE) {<br>
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);<br>
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);<br>
}<br><br>
if ($httpMethod == 'GET') {<br>
curl_setopt($oCurl, CURLOPT_URL, $url . "?" . http_build_query($param));<br>
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);<br>
} else {<br>
curl_setopt($oCurl, CURLOPT_URL, $url);<br>
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);<br>
curl_setopt($oCurl, CURLOPT_POST, 1);<br>
curl_setopt($oCurl, CURLOPT_POSTFIELDS, http_build_query($param));<br>
}<br><br>
$sContent = curl_exec($oCurl);<br>
$aStatus = curl_getinfo($oCurl);<br>
curl_close($oCurl);<br>
if (intval($aStatus["http_code"]) == 200) {<br>
return $sContent;<br>
} else {<br>
return FALSE;<br>
}<br>
}
AD:真正免费,域名+虚机+企业邮箱=0元
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号