对web服务的cURL调用不起作用


cURL call to web service not working

我正在尝试对位于https://salesgenie.com/brandingservice/details?url=att.salesgenie.com进行cURL调用的测试页面位于https://test-cms.salesgenie.com/wp-content/themes/salesgenie/branding-proxy.phpweb服务可以在浏览器中调用,但通过cURL调用时超时。以下是来自branding-proxy.php页面的代码:

if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}       
$url = 'https://salesgenie.com/brandingservice/details?url=att.salesgenie.com';
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($handle, CURLOPT_SSLVERSION,3);
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
setcookie('CmsCookie', $code . '    ' . $response, 0, '/', 'salesgenie.com', 0);
echo 'Code:' . $code."<br />Response: ".$response;

我可以看到在使用链接时发生了超时,尽管我认为问题发生在其他地方。我得出这个结论的原因是我把你的代码上传到了我自己的网站上。它运行良好。

重要

如果你是salesgenie.com的所有者,那么我认为你的服务器有问题,因为有时我得到的响应要么是超时(代码0),要么是代码200(带结果),要么就是代码320。因此,问题可能是服务器本身的问题。

技巧

  • 请尝试删除setcookie以留出一些处理时间
  • 也可以尝试使用http而不是https,因为https需要更多的处理才能使用