powered by Jive Software

XMPPHP question - how to create a new user?

Hi,

I’m not sure if this is the right place to ask questions about XMPPHP (the xmpp php solution), but it’s all I could find. Please redirect me to the right place if I’m wrong.

My question about XMPPHP is, how do I create a brand new user, ie. not just add a known user to a roster, but create a brand new one - including their name, password, jid, and whatever else is needed. Ideally my end result would be a simple .php script which creates a new user, who then immediately appears on my list of contacts in my XMPP chat client application.

Surely it is possible to IM create users through php code? I would ideally like to achieve this with only XMPPHP and no additional plugins, but I would be grateful for any advice, I’m rather new at this.

Thanks

Owen

Please if anybody out there has any clues, I still need urgent help with this.

I have tried the following but it doesn’t work.

<?php require_once "HTTP/Request.php"; include 'XMPPHP/XMPP.php'; **// first, try to create the new user by posting an XML request //** $jid = "owentestuser1@mydomain.co.uk"; $pwd = "1234"; $email = "testuser1@mydomain.co.uk"; $firstname = "Owen"; $surname = "Tester"; $adminjid = "myname@mydomain.co.uk"; $domain = "gmail.com"; $adminurl = "[http://www.jabber.org/protocol/admin](http://www.jabber.org/protocol/admin)"; $commandurl = "[http://jabber.org/protocol/commands](http://jabber.org/protocol/commands)"; $url = "talk.google.com"; $xml = "" . "" . "" . "" . "{$adminurl}" . "" . "" . "{$jid}" . "" . "" . "{$pwd}" . "" . "" . "{$pwd}" . "" . "" . "{$email}" . "" . "" . "{$firstname}" . "" . " " . "{$surname}" . "" . "" . "" . ""; print "=======================================\n"; print "{$xml}\n"; $req =& new HTTP_Request($url); $req->addHeader("Content-Type", "text/xml"); $req->addHeader("Content-Length", strlen($xml)); $req->setMethod(HTTP_REQUEST_METHOD_POST); $req->addRawPostData($xml, true); $req->sendRequest(); $result = $req->getResponseBody(); print "=======================================\n"; print "Posted to {$url}\n"; print "Result: {$result}\n"; **// ??? seems to be blank every time - wot, no result? did it work or not ???? //** print "=======================================\n"; **// now, connect to IM server //** print "Connecting.\n"; $conn = new XMPPHP_XMPP('talk.google.com', 5222, 'myadminjid@mydomain.co.uk', 'passwd', 'xmpphp', 'gmail.com', $printlog=false, $loglevel=XMPPHP_Log::LEVEL_INFO); $conn->connect(); print "Connected.\n"; print "Adding Contact to Roster.\n"; **// try to add the newly created contact to roster, so they show up on myadminjid's list of contacts (this does not work either!) ///** $conn->roster->addContact($jid,'chat');** ** print "\nFinished.\n"; ?>

… Please help me ?!

Thanks!

Owen

Forget it, I gave up and used the UserService in openfire.