InventoryService

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(API)
(API)
Line 61: Line 61:
 
     curl_setopt($ch, CURLOPT_POST, TRUE);
 
     curl_setopt($ch, CURLOPT_POST, TRUE);
 
     curl_setopt($ch, CURLOPT_POSTFIELDS, "PRINCIPAL=efc1b931-20e3-4298-8824-0f891fe3dc59&METHOD=GETROOTFOLDER");
 
     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";
 +
   
 +
?>
 +
</source>
 +
 +
== GETFOLDER ==
 +
 +
This returns data about a particular inventory folder.  POST field is a urlencoded string like so
 +
 +
ID=efc1b932-20e3-4298-8824-0f891fe3dc59&METHOD=GETFOLDER
 +
 +
where
 +
 +
* '''METHOD''' is GETFOLDER
 +
* '''ID''' is the folder UUID
 +
 +
If successful, example return is
 +
 +
<source lang="xml">
 +
<?xml version="1.0"?>
 +
<ServerResponse>
 +
  <folder type="List">
 +
    <ParentID>035f457b-a0f6-4580-a10c-e4f908e176ac</ParentID>
 +
    <Type>8</Type>
 +
    <Version>1</Version>
 +
    <Name>Some folder</Name>
 +
    <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
 +
    <ID>e3c2a5e8-20c4-4e70-a994-61dae3265b58</ID>
 +
  </folder>
 +
</ServerResponse>
 +
</source>
 +
 +
If the request fails (e.g. because the PRINCIPAL does not exist) you will receive an empty response
 +
 +
<source lang="xml">
 +
<?xml version="1.0"?><ServerResponse />
 +
</source>
 +
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 [https://github.com/openmetaversefoundation/libopenmetaverse/blob/master/OpenMetaverseTypes/Enums.cs libopenmetaverse] for more details.  In this case, the type is 8 (Folder) since this is an ordinary non-system 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 ===
 +
 +
<source lang="php">
 +
<?php
 +
 +
    $ch = curl_init("http://localhost:8003/xinventory");
 +
   
 +
    curl_setopt($ch, CURLOPT_POST, TRUE);
 +
    curl_setopt($ch, CURLOPT_POSTFIELDS, "ID=e3c2a5e8-20c4-4e70-a994-61dae3265b58&METHOD=GETFOLDER");
 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 
      
 
      

Revision as of 12:12, 13 September 2012

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";
 
?>

GETFOLDER

This returns data about a particular inventory folder. POST field is a urlencoded string like so

ID=efc1b932-20e3-4298-8824-0f891fe3dc59&METHOD=GETFOLDER

where

  • METHOD is GETFOLDER
  • ID is the folder UUID

If successful, example return is

<?xml version="1.0"?>
<ServerResponse>
  <folder type="List">
    <ParentID>035f457b-a0f6-4580-a10c-e4f908e176ac</ParentID>
    <Type>8</Type>
    <Version>1</Version>
    <Name>Some folder</Name>
    <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
    <ID>e3c2a5e8-20c4-4e70-a994-61dae3265b58</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 is 8 (Folder) since this is an ordinary non-system 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, "ID=e3c2a5e8-20c4-4e70-a994-61dae3265b58&METHOD=GETFOLDER");
    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";
 
?>
Personal tools
General
About This Wiki