首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VESTA,API,PHP。未添加用户

VESTA,API,PHP。未添加用户
EN

Stack Overflow用户
提问于 2018-07-19 05:58:48
回答 0查看 614关注 0票数 2

我正在写一个脚本来添加一个新用户到主机控制面板"VESTA“。我根据手册写的api:http://vestacp.com/docs/api/错误时执行的代码不会产生,但用户没有添加到VESTA中。我的代码:

代码语言:javascript
复制
$vst_hostname = 'dfsdfl.csfdsdsgds.com';

$postvars = array(
$vst_username = 'zdeslogin',
$vst_password = 'zdesparol',
$vst_returncode = 'yes',
$vst_command = 'v-add-user',
$username = 'demo',
$password = 'password',
$email = 'demo@gmail.com',
$package = 'default',
$fist_name = 'Rust',
$last_name = 'Cohle'
);

$postdata = http_build_query($postvars);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
// Check result
if($answer == 0) {
    echo "User account has been successfuly created\n";
} else {
    echo "Query returned error code: " .$answer. "\n";
}

运行代码后,返回以下行:用户帐户已成功创建。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51411572

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档