Ryzom API/Gilde: Unterschied zwischen den Versionen
Aus EnzyklopAtys
Leda (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<noinclude>{{Trad|DE=Ryzom API/Gilde|EN=Ryzom API/Guild|palette=api|H=1}}</noinclude> Access to guild information. === Usage === <base URL>/guild.php?apikey…“) |
Leda (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
<noinclude>{{Trad|DE=Ryzom API/Gilde|EN=Ryzom API/Guild|palette=api|H=1}}</noinclude> | <noinclude>{{Trad|DE=Ryzom API/Gilde|EN=Ryzom API/Guild|palette=api|H=1}}</noinclude> | ||
− | + | Zugang zu Gilden-Informationen. | |
− | === | + | === Verwendung === |
<base URL>/guild.php?apikey=key | <base URL>/guild.php?apikey=key | ||
<base URL>/guild.php?apikey[]=key1&apikey[]=key2 | <base URL>/guild.php?apikey[]=key1&apikey[]=key2 | ||
− | ==== URL | + | ==== URL-Parameter ==== |
;apikey : | ;apikey : | ||
− | : | + | : Gilden-API-Schlüssel beginnt mit 'g' |
==== Cache Duration ==== | ==== Cache Duration ==== |
Version vom 27. Mai 2023, 11:44 Uhr
Zugang zu Gilden-Informationen.
Inhaltsverzeichnis
Verwendung
<base URL>/guild.php?apikey=key <base URL>/guild.php?apikey[]=key1&apikey[]=key2
URL-Parameter
- apikey
- Gilden-API-Schlüssel beginnt mit 'g'
Cache Duration
Guild xml element has attributes created and cached_until (utc timestamp)
XML structure
API is able to return information for multiple guilds at once and so each <guild> element is a child of <ryzomapi> root elements
<ryzomapi> <guild apikey="key1" created"1387369332" modules="G01:G02:G03:G04:P01" cached_until="1387369632"> ... </guild> <guild apikey="key2" created"1387369332" modules="P01" cached_until="1387369632"> ... </guild> </ryzomapi>
Invalid key error:
<guild apikey="key1" created="1387369873">
<error code="404">invalid key</error>
</guild>
Possible error codes are listed on API error codes.
PHP interface
ryzom_guild_api($apikey)
$apikey can be either a string or array of strings
Function will return associative array of SimpleXMLElement with $apikey as array index On failure function returns boolean false
<?php require_once "ryzomapi_lite.php"; function info($guild) { if (isset($guild->error)) { $apikey = htmlspecialchars($guild['apikey']); $error = htmlspecialchars($guild->error); $code = (int)$guild->error['code']; echo "Gilden-API-Schlüssel '{$apikey}' gescheitert: {$code}:{$error}"; } else { $name = htmlspecialchars($guild->name); echo "Gilden-Name: {$name}"; } } $apikey = 'gABCDEF'; $guilds = ryzom_guild_api($apikey); if ($guilds !== false) { info($guilds[$apikey]); } else { echo "Gilden-API gescheitert"; } $apikeys = ['gABCDEF', 'g123456']; $guilds = ryzom_guild_api($apikeys); if ($guilds !== false) { foreach($guilds as $guild) { info($guild); } } else { echo "Gilden-API gescheitert"; }