/**
* 发送HTTP请求并获得响应
* @param url 请求的url地址
* @param param 发送的http参数
*/
* 发送HTTP请求并获得响应
* @param url 请求的url地址
* @param param 发送的http参数
*/
function makeRequest($url, $param, $httpMethod = 'GET') {
$oCurl = curl_init();
if (stripos($url, "https://") !== FALSE) {
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
}
if ($httpMethod == 'GET') {
curl_setopt($oCurl, CURLOPT_URL, $url . "?" . http_build_query($param));
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
} else {
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($oCurl, CURLOPT_POST, 1);
curl_setopt($oCurl, CURLOPT_POSTFIELDS, http_build_query($param));
}
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if (intval($aStatus["http_code"]) == 200) {
return $sContent;
} else {
return FALSE;
}
}