0

正常工作的命令行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);

但是上面的代码不起作用。我在代码中做错了什么?

4

0 回答 0