正常工作的命令行Curl是:
curl --data username=ekansh&domain=siteURL&password=mypass
http://siteURL:8090/add-user -k -v -u apiuser:XXXXXXX
我已尝试使用以下代码将其转换为PHP CURL CODE:
$fields = array('domain' => 'SiteUrl:8090','password' => 'mypass','username' => 'Ekansh');
$data=array(CURLOPT_POST => 1,CURLOPT_HEADER => 0,CURLOPT_URL =>
'SiteUrl:8090/add-user ',CURLOPT_FRESH_CONNECT => 1,CURLOPT_RETURNTRANSFER =>
1,CURLOPT_FORBID_REUSE =>
1,CURLOPT_TIMEOUT => 4,CURLOPT_POSTFIELDS => $fields,CURLOPT_SSL_VERIFYPEER =>
FALSE,CURLOPT_USERPWD => 'apiuser:XXXXXXX',CURLOPT_VERBOSE=>TRUE);
$ch = curl_init();
curl_setopt_array($ch,$data);
$result=curl_exec($ch);
curl_close($ch);
但上面的代码不起作用。我在代码中做错了什么?