我的服务器上有一个简单的 PHP Web 服务。
我可以使用以下代码连接到此服务而不会出现任何错误(我已删除我们的域):
$service_url = '*** ADDRESS REDACTED! *** /getroomsforcategories.php';
$curl = curl_init();
$curl_post_data = array(
"categoryids" => 1
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_URL,$service_url."?categoryids=1");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . "/cacert.pem");
$curl_response = curl_exec($curl);
if ($curl_response===false)
echo "<p>Error ".curl_errno($curl)." - ".curl_error($curl);
else
{
echo "<pre>The CURL information: \n";
print_r(curl_getinfo($curl));
echo "The response using cURL was: \n";
print_r($curl_response);
echo "</pre>";
curl_close($curl);
}
我没有得到任何错误,它似乎连接得很好(返回 HTTP 代码 200)。
curl信息显示如下:
Array
(
[url] => *** REDACTED *** /getroomsforcategories.php?categoryids=1
[content_type] => text/html
[http_code] => 200
[header_size] => 348
[request_size] => 120
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.125
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0.109
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.125
[redirect_time] => 0
[certinfo] => Array
(
)
[redirect_url] =>
)
但是,curl 响应是完全空的。
Web 服务本身运行良好——它在我们的软件中通过 AJAX 使用 jQuery 调用并且运行良好。
关于我缺少的东西的任何想法?