当我尝试在 php 中向服务器发送请求时,我似乎遇到了问题。http api 请求是这样的:
我在 php 中有以下代码部分,我认为错误正在发生:
else
{
$ch = curl_init($input);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_POST, true);
$this->input = $input;
}
$r = curl_exec($ch);
print_r(curl_getinfo($ch));
if($return_xml) {
$response = new SimpleXMLElement($r);
}
这是我从 print_r(curl_getinfo($ch)) 语句中得到的:
[content_type] => text/html [http_code] => 400 [header_size] => 129 [request_size] => 251 [filetime] => -1 [ssl_verify_result] => 20 [redirect_count] => 0 [total_time] => 0.281 [namelookup_time] => 0 [connect_time] => 0.063 [pretransfer_time] => 0.188 [size_upload] => 0 [size_download] => 20 [speed_download] => 71 [speed_upload] => 0 [download_content_length] => 20 [ upload_content_length] => 0 [starttransfer_time] => 0.281 [redirect_time] => 0 [certinfo] => 数组 ()
此外,您可以看到我注释掉了 curlopt_post,这是因为当我执行不同的 api 请求时它会导致问题。我不确定解决方案是什么,我一直在研究这个问题一段时间,希望有人能帮助我,谢谢:)