[Opensim-users] UserManipulation PHP

Justin Clark-Casey jjustincc at googlemail.com
Tue Oct 29 00:40:20 UTC 2013


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
> Opensim-users at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/opensim-users
>


-- 
Justin Clark-Casey (justincc)
OSVW Consulting
http://justincc.org
http://twitter.com/justincc



More information about the Opensim-users mailing list