Access character information.

Contents

Usage

<base URL>/character.php?apikey=key
<base URL> /character.php?apikey[=key1&apikey[]=key2

URL Parameters

apikey
Character API key starting with 'c'

Cache Duration

<character> xml element has attributes *created* and *cached_until* (utc timestamp)

XML structure

API is able to return information about multiple characters at once and so each <character> element is child of <ryzomapi> root element:

<ryzomapi>
  <character apikey="key1" created="1387369332" modules="C01:P01" cached_until="1387369632">
    ....
  </character>
  <character apikey="key2" created="1387369332" modules="P01" cached_until="1387369632">
    ....
  </character>
</ryzomapi>

Invalid key error:

<character apikey="key1" created="1387369873">
  <error code="404">invalid key</error>
</character>

Possible error codes are listed on API error codes.

PHP interface

ryzom_character_api($apikey)
$apikey can be either string (single key) or array of strings.
On success, function returns associative array of SimpleXMLElement with apikey as array index.
On failure, function returns boolean false.

<?php require_once "ryzomapi_lite.php";

function info($char) {
  if (isset($char->error)) {
    $apikey = htmlspecialchars($char['apikey']);
    $error = htmlspecialchars($char->error);
    $code = (int)$char->error['code'];
    echo "Character API key '{$apikey}' failed: {$code}:{$error}";
  } else {
    $name = htmlspecialchars($char->name);
    echo "Character name: {$name}";
  }
}:
$apikey = 'cABCDEF';
$chars = ryzom_character_api($apikey);
if ($chars !== false) {
  info($chars[$apikey]);
} else {
  echo "Character API failed";
}
$apikeys = ['cABCDEF', 'c123456'];
$chars = ryzom_character_api($apikeys);
if ($chars !== false) {
  foreach($chars as $char) {
    info($char);
  }
} else {
  echo "Character API failed";
}
Retrieved from "https://en.wiki.ryzom.com/w/index.php?title=Ryzom_API/Character&oldid=37816"