Skip to content

Instantly share code, notes, and snippets.

@heavygale
Created October 18, 2017 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heavygale/ea95e9636904a4d7cb3cba7949e7916a to your computer and use it in GitHub Desktop.
Save heavygale/ea95e9636904a4d7cb3cba7949e7916a to your computer and use it in GitHub Desktop.
// replace everything that's written in uppercase with your own values
// USERNAME@DOMAIN.TLD needs to be a user who has administrative privileges
function jabber_add_user($username, $password)
{
$data = json_encode(array('password' => $password));
curl_setopt_array(
$ch = curl_init(),
array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'http://localhost:5280/admin_rest/user/'.$username,
CURLOPT_USERPWD => 'USERNAME@DOMAIN.TLD:PASSWORD',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array('Host: DOMAIN.TLD', 'Content-Type: application/json', 'Content-Length: '.strlen($data))
)
);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $code;
}
jabber_add_user('NEW_USER', 'PASSWORD');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment