public function request($requestURL,$params='',$method ='GET',$contentType='',$user=''){
$timeout = 30;
$ch = null;
if ('POST' === strtoupper($method)) {
$ch = curl_init($requestURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
if (is_string($params)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
}
} else if('GET' === strtoupper($method)) {
if(is_string($params)) {
$real_url = $requestURL. (strpos($requestURL, '?') === false ? '?' : ''). $params;
} else {
$real_url = $requestURL. (strpos($requestURL, '?') === false ? '?' : ''). http_build_query($params);
}
$ch = curl_init($real
PHP框架调用Java后端,参数传递不过去的问题解决
最新推荐文章于 2025-05-01 15:59:06 发布
本文主要介绍了在PHP框架调用Java后端服务时遇到的参数传递问题。通过检查请求的Content Type,发现之前设置的是text/html,而正确的方式是不设置或者设置为默认的application/x-www-form-urlencoded,这样可以成功传递参数。

最低0.47元/天 解锁文章
2002

被折叠的 条评论
为什么被折叠?



