Quantcast
Channel: Proxmox Support Forum
Viewing all articles
Browse latest Browse all 171679

Proxmox API create users

$
0
0
Hello,

I am working on a free WHMCS module for Proxmox, that (if I can pull it off) I want to release to the public.

I have messed around and hacked up PHP scripts for years but never created or taken on a project like this. So please forgive me if my question are too noobish.

I have been trying to create/modify/suspend/delete users with the API but I have hit a snag and don't entirely understand the syntax. I am using the (awesome) API documentation at: http://pve.proxmox.com/pve2-api-doc/.

Are there example PHP scripts for the Proxmox API out there? I've googled around and don't see any. Any examples of creating users with the API or pvesh would be greatly appreciated!

Thanks,

--Will

**EDIT**

Figured it out :) for anyone who needs it, hear is a some sample code (rough modification of the example PHP API):
<html>
<body>
<?php
require("./pve2_api.class.php");

$pve2 = new PVE2_API("<proxmox_server_ip>", "root", "pam", "password");
# realm above can be pve, pam or any other realm available.
if ($pve2->constructor_success()) {

/* Optional - enable debugging. It print()'s any results currently */
$pve2->set_debug(true);

if ($pve2->login()) {

# Get first node name.
$nodes = $pve2->get_node_list();
$first_node = $nodes[0];
unset($nodes);

$new_user_settings = array();
$new_user_settings['userid'] = "cust01@pve";
$new_user_settings['email'] = "cust01@test.com";
$new_user_settings['enable'] = "1";
$new_user_settings['password'] = "12345";

// print_r($new_user_settings);
print("---------------------------\n");

print_r($pve2->post("/access/users", $new_user_settings));
print("\n\n");
} else {
print("Login to Proxmox Host failed.\n");
exit;
}
} else {
print("Could not create PVE2_API object.\n");
exit;
}

?>
</body>
</html>

Viewing all articles
Browse latest Browse all 171679

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>