cURL がインストールされ、機能しているかどうかをテストするために使用している小さな php スクリプトがあります。これは、Oracle Service Cloud サンドボックス環境 (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>