UserManipulation PHP

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

UserManipulation PHP

hack13
So I am attempting to write PHP version of "createuser" request
because all this page has is python examples
http://opensimulator.org/wiki/UserManipulation but I am getting a
strange response back:  PHP Notice: xmlrpc: Requested method
[createuser] not found (-32601)
_______________________________________________
Opensim-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/opensim-users
Reply | Threaded
Open this post in threaded view
|

Re: UserManipulation PHP

hack13
it might help if I show you my code

http://pastebin.com/qr12JJT3
Reply | Threaded
Open this post in threaded view
|

Re: UserManipulation PHP

justincc
The chief issue you have is that these are vanilla POST calls, not XMLRPC.  Instead, you want something like

function PostToService($uri, $postFields, $debug = FALSE)
{
     if ($debug)
         echo "postFields:$postFields\n";

     $ch = curl_init($uri);

     curl_setopt($ch, CURLOPT_POST, TRUE);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

     $result = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);

     if ($debug)
         PrintReturnDebugInfo($result, $info);

     return new SimpleXmlElement($result);
}

function CreateUser($serviceUri, $firstName, $lastName, $password, $debug = FALSE)
{
     $params
         = array(
             'FirstName' => $firstName,
             'LastName' => $lastName,
             'Password' => $password,
             'METHOD' => "getaccount");

     $responseXml = PostToService($serviceUri, http_build_query($params), $debug);

     // At the moment we take advantage of the fact that only errors will return a <result>
     if ($responseXml->result == "null")
         return null;
     else
         return $responseXml;
}

this uses CURL to send a POST request.  The above is not guaranteed to work straight off - I adapted it from somethig
else but it should be close.

On 26/10/13 18:48, hack13 wrote:

> it might help if I show you my code
>
> http://pastebin.com/qr12JJT3
>
>
>
> --
> View this message in context: http://opensim-users.2152040.n2.nabble.com/UserManipulation-PHP-tp7580560p7580561.html
> Sent from the opensim-users mailing list archive at Nabble.com.
> _______________________________________________
> Opensim-users mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/opensim-users
>


--
Justin Clark-Casey (justincc)
OSVW Consulting
http://justincc.org
http://twitter.com/justincc
_______________________________________________
Opensim-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/opensim-users