【发布时间】:2015-11-10 14:34:04
【问题描述】:
我有一个小的 php 脚本,用于测试 cURL 是否已安装并正常运行。这适用于我们的 Oracle 服务云沙箱环境(websitename.rightnowdemo.com),它在页面顶部和下方显示 google.com,它打印测试功能的结果(“cURL 已安装在此服务器上”) .但是,我们的开发 (websitename.custhelp.com) 环境中的相同代码不起作用。它只打印“cURL 已安装”消息,仅此而已。在我们的新环境中是否有需要设置的配置设置?我怎样才能让 cURL 充分发挥作用?
代码:
<rn:meta title="cURL Example" template="agent.php" clickstream=""/>
<?php
load_curl();
$curlURL = "www.google.com";
$ch = curl_init($curlURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
?>
<html>
<head></head>
<body>
<?php
// Script to test if the CURL extension is installed on this server
// Define function to test
function _is_curl_installed() {
if (in_array ('curl', get_loaded_extensions())) {
return true;
}
else {
return false;
}
}
// Ouput text to user based on test
if (_is_curl_installed()) {
echo "cURL is <span style=\"color:#4fa361;\">installed</span> on this server";
} else {
echo "cURL is <span style=\"color:#dc4f49\">not installed</span> on this server";
}
?>
</body>
</html>
【问题讨论】:
-
为什么还要打一个 curl 调用来检查是否安装了 curl?为什么不使用
http://www.google.com作为 URL? -
我们已经尝试了 URL 的所有组合,上面代码中的 URL 只是在我们的沙盒站点上尝试并运行的最后一个。在将一些文件从一种环境迁移到另一种环境后,我们注意到了一些问题。使用 cURL 的脚本在一个沙箱中运行良好,但在开发人员中却无法运行。 cURL 调用只是这里某人确保库可用的额外手段。
标签: php curl crm rightnow-crm oracle-service-cloud