require_once '../hessian/HessianClient.php';
require_once './gametool.inc.php';
require_once './ServerVersion.inc.php';
$url = 'http://localhost:8080/gametool';
// gametool is protected by username/pwd
$options = array('username' => 'vzlobin', 'password' => '1');
$version = 1;
$serverVer = new ServerVersion($url, 'hessian/account.api', $options);
$path = $serverVer->getVersionPath($version);
if (empty($path)) {
    die("Failed to determine path to account api version {$version}");
}
$proxy = new HessianClient($url . $path, $options);
registerGametoolMethods($url . $path);
// determine all shards known to gametool
$result = $proxy->getAllShards();
echo "Shards =\n";
foreach ($result as $shard) {
    echo "  {$shard}\n";
}
// request avatars of account
// also demonstrate how we can work with Russian-named elements, assuming that php script is in cp1251 encoding
$account = 'вататар';
$result = $proxy->getAvatars(iconv('Windows-1251', 'UTF-8', $account));
echo "Avatars of {$account}=\n";
foreach ($result as $avatar) {
    echo "  {$avatar->getAvatar()}\n";
    var_export($avatar);
}
// give item to avatar 1 on shard
$shard = "trunk_gametool";