1

I used below code to post data using cURL in PHP. And I am getting error like "Could not resolve host". And I am using IBM Bluemix and installed cURL plugin and enabled it.

$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);

1 Answers1

0

In case someone wanders in looking for a solution, here is one that worked for me. In the root directory (the outermost level), make a .bp-config directory. Inside it, make an options.json file. Put following code in this options.json file:

{
    "PHP_EXTENSIONS": ["pdo", "mysqli", "pdo_mysql", "mysql", "curl"]
}

Save it and do the cf push. (Note: For my application, I needed extensions apart from curl too; hence you see pdo, mysqli etc too along with curl in there)

Ankit Shubham
  • 2,989
  • 2
  • 36
  • 61