PHP curl无法解析bluemix上的主机

PHP curl无法解析bluemix上的主机,php,curl,ibm-cloud,ibm-cloud-plugin,Php,Curl,Ibm Cloud,Ibm Cloud Plugin,我使用下面的代码在PHP中使用cURL发布数据。我得到的错误是“无法解析主机”。我正在使用IBMBlueMix,安装了cURL插件并启用了它 $ch = curl_init($url); $headers = array( 'Accept: application/json', 'Content-Type: application/json' ); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 )

我使用下面的代码在PHP中使用cURL发布数据。我得到的错误是“无法解析主机”。我正在使用IBMBlueMix,安装了cURL插件并启用了它

$ch = curl_init($url);  
$headers = array(  
    'Accept: application/json',  
    'Content-Type: application/json'  
);  

curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);  
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);  
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 30 );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));  


$result = curl_exec($ch);  
$ch_error = curl_error($ch);

if ($ch_error) {  
    echo "cURL Error: $ch_error";  
} else {  
    echo $result;       
}

curl_close($ch);

如果有人无意中寻找解决方案,这里有一个对我有用的。在根目录(最外层)中,创建一个
.bp config
目录。在它里面,创建一个
options.json
文件。将以下代码放入此
options.json
文件中:

{
    "PHP_EXTENSIONS": ["pdo", "mysqli", "pdo_mysql", "mysql", "curl"]
}
保存它并执行
cf推送操作

(注意:对于我的应用程序,除了curl之外,我还需要扩展;因此您可以看到pdo、mysqli等以及curl)

如果有人无意中寻找解决方案,这里有一个适合我的解决方案。在根目录(最外层)中,创建一个
.bp config
目录。在它里面,创建一个
options.json
文件。将以下代码放入此
options.json
文件中:

{
    "PHP_EXTENSIONS": ["pdo", "mysqli", "pdo_mysql", "mysql", "curl"]
}
保存它并执行
cf推送操作

(注意:对于我的应用程序,除了curl之外,我还需要扩展;因此您可以看到pdo、mysqli等以及curl)

如果您具有shell访问权限,请尝试解析shell上的主机。您的URL是否位于防火墙后?如果您具有shell访问权限,请尝试解析shell上的主机。您的URL是否位于防火墙后?