InventoryService
From OpenSimulator
Contents |
Introduction
The OpenSimulator inventory service stores user inventory data (object items, notecard items, folders, etc.) and provides this on request. Note that every inventory item points towards an immutable asset entry that actually contains the data.
The current default ROBUST OpenSimulator inventory service is known as the XInventoryService.
API
General notes
Unlike the asset service, the xinventory service is an RPC interface. Therefore it exposes only one URI which is xinventory (e.g. http://localhost:8003/xinventory). The invocation of different operations (e.g. add item, get item) is controlled via a METHOD parameter.
GETROOTFOLDER
This returns data about a user's root folder (i.e. their "My Inventory" folder"). POST field is a urlencoded string like so
PRINCIPAL=efc1b932-20e3-4298-8824-0f891fe3dc59&METHOD=GETROOTFOLDER
where
- METHOD is GETROOTFOLDER
- PRINCIPAL is the UUID of the user
If successful, example return is
<?xml version="1.0"?> <ServerResponse> <folder type="List"> <ParentID>00000000-0000-0000-0000-000000000000</ParentID> <Type>9</Type> <Version>1</Version> <Name>My Inventory</Name> <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner> <ID>035f457b-a0f6-4580-a10c-e4f908e176ac</ID> </folder> </ServerResponse>
If the request fails (e.g. because the PRINCIPAL does not exist) you will receive an empty response
<?xml version="1.0"?><ServerResponse />
where
- ParentID is the parent folder ID. Since this is the root folder this is always UUID.Zero (00000000-0000-0000-0000-000000000000).
- Type is the type of the folder. See the InventoryType enum in libopenmetaverse for more details. In this case, the type will always be 9 (RootCategory) since this is the root folder.
- Version is the version of the folder. This is used for viewer inventory caching purposes.
- Name is the name of the folder.
- Owner is the UUID of the avatar that owns the folder (this will always match the PRINCIPAL in our request).
- ID is the unique id of the folder itself.
Sample scripts
<?php $ch = curl_init("http://localhost:8003/xinventory"); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, "PRINCIPAL=efc1b931-20e3-4298-8824-0f891fe3dc59&METHOD=GETROOTFOLDER"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); echo "Return code:" . $info['http_code'] . "\n"; echo "$result\n"; ?>