I want to Implement following Command Line CURL into PHP CURL Request.
curl --data username=ekansh&domain=siteURL&password=mypass
http://siteURL:8090/add-user -k -v -u apiuser:yru3472825fhj
I have tried below code for the same:
$fields = array('domain'=> 'siteURL','password'=> 'mypass','apiuser'=>
'yru3472825fhj','username'=> 'ekansh');
$data=>array(CURLOPT_POST => 1,CURLOPT_HEADER => 0,CURLOPT_URL =>
$url,CURLOPT_FRESH_CONNECT => 1,CURLOPT_RETURNTRANSFER => 1,CURLOPT_FORBID_REUSE =>
1,CURLOPT_TIMEOUT => 4,CURLOPT_POSTFIELDS => http_build_query($_POST));
$ch = curl_init();
$options=$fields+$defaults;
curl_setopt_array($ch,$options);
$result=curl_exec($ch)
curl_close($ch);
But this is not working .. i am not getting any response in $result. How could i will implement above code?
UPDATE
$fields = array('domain' => 'siteurl','password' => 'mypass',
'apiuser'=> 'yru3472825fhj','username'=> 'ekansh');
$data=array(CURLOPT_POST => 1,CURLOPT_HEADER => 0,CURLOPT_URL =>
'siteurl',CURLOPT_FRESH_CONNECT => 1,CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,CURLOPT_TIMEOUT => 4,
CURLOPT_POSTFIELDS => $fields);
$ch = curl_init();
curl_setopt_array($ch,$data);
$result=curl_exec($ch);
curl_close($ch);
I have modified above code but it still not working.
+does not seem to work on arrays; 2) You may mistakenly set curl options to$optionsinstead of$data.