【发布时间】:2013-08-12 17:58:56
【问题描述】:
我正在尝试在https://salesgenie.com/brandingservice/details?url=att.salesgenie.com 对 .NET RESTful Web 服务进行简单的 get 调用。进行 cURL 调用的测试页面位于https://test-cms.salesgenie.com/wp-content/themes/salesgenie/branding-proxy.php 可以在浏览器中调用 Web 服务,但调用时会超时通过卷曲。这是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;
【问题讨论】:
-
您尝试添加
CURLOPT_USERAGENT和CURLOPT_HEADER吗? -
我已经尝试使用 Content-type 的 HEADER 和使用组合代理的 USERAGENT。
-
嗯...我将运行一些测试然后发布答案。
-
看来我们的测试环境服务器的 IP 被我们的基础架构团队阻止调用我们的 .NET 应用程序。相同的代码能够在我们的开发和生产环境中可靠地运行。谈论用头撞墙……然后发现有人把墙挡在了你的路上。 叹息
-
那么我实际上是对的,在某些方面。
标签: php web-services curl restful-url