承接 renatorib/otinfo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

renatorib/otinfo

Composer 安装命令:

composer require renatorib/otinfo

包简介

Open Tibia Server Info Parser

README 文档

README

Catch information from servers' response by ip and port

Install

Just download this repo, and include otinfo.php Important: Must have a writable cache folder in the same level of otinfo.php or will not work correctly

include('otinfo.php');

Get started

To instantiate an otserv, create a new Otinfo object

$server = new Otinfo\Otinfo('shadowcores.twifysoft.net');

The first parameter is the server $ip, and the second is the $port (defined 7171 as default)

Get informations

if ($server->execute()) {
  echo "Players online: " . $server->players['online'] . "<br />";
  echo "Server location: " . $server->serverinfo['location'] . "<br />";
  echo "Client version: " . $server->serverinfo['client'] . "<br />";
  // these are just a few examples
} else {
  echo "Server offline";
  // if execute() returns false, the server are offline
}

The `execute()' method catch/parse the responses returned by server and return false if server are offline.

Possible responses

Each server has its own response, and may be different from the others. This means that not all respond with the same information, and a server may have information that others do not have.

Here are some possible answers nodes

  • players
  • serverinfo
  • motd
  • owner
  • monsters
  • map
  • npcs
  • maybe others

This means if you want to test, can print_r, var_dump, and whatelse, the nodes to know returned responses

print_r($server->players);
print_r($server->serverinfo);
//etc

Cache

Otinfo cache itself not only for performance, but also to avoid empty responses, caused due to the protection of tfs. As said before, you must have a writable cache folder in the same level of otinfo.php or will not work correctly. The time of cache as default 180 seconds (three minutes). May you edit in otinfo.php changing this line

private static $cache = 180; //seconds you want

Timeout

When the connection is bad, you can increase the timeout

private static $timeout = 5; //seconds you want

Made with ❤️ by Renato Ribeiro and Ranieri Althoff

Contributors - my heartfelt thanks

  • gpedro
  • rmobis
  • yrpen
  • DSpeichert

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 9
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-20