cURL调用Web服务无法正常工作

时间:2013-08-12 17:58:57

标签: php web-services curl restful-url

我试图在https://salesgenie.com/brandingservice/details?url=att.salesgenie.com对.NET RESTful Web服务进行简单的调用调用cURL调用的测试页面位于https://test-cms.salesgenie.com/wp-content/themes/salesgenie/branding-proxy.php可以在浏览器中调用Web服务,但是通过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;

1 个答案:

答案 0 :(得分:0)

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

重要

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

技巧

  • 尝试删除setcookie以便进行一些处理。
  • 同时尝试使用http代替https,因为https需要更多处理才能使用。
相关问题