1: <?php
2: /**
3: * Maniaplanet Web Services SDK for PHP
4: *
5: * @see http://code.google.com/p/maniaplanet-ws-sdk/
6: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
7: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
8: * @author $Author: baptiste33@gmail.com $:
9: * @version $Revision: 171 $:
10: * @date $Date: 2012-12-03 11:15:02 +0100 (lun., 03 déc. 2012) $:
11: */
12:
13: namespace Maniaplanet\WebServices;
14:
15: class Servers extends HTTPClient
16: {
17:
18: const ALL_MODES = -1;
19: const OFFICIAL_MODES = -2;
20: const CUSTOM_MODES = -3;
21:
22: /**
23: * Returns information about the specified server
24: *
25: * @param string $login
26: * @return object
27: */
28: function get($login)
29: {
30: if(!$login)
31: {
32: throw new Exception('Invalid login');
33: }
34: return $this->execute('GET', '/servers/%s/', array($login));
35: }
36:
37: /**
38: * Return online players for the given server
39: * @param string $login
40: * @return object[]
41: * @throws Exception
42: */
43: function getOnlinePlayers($login)
44: {
45: if(!$login)
46: {
47: throw new Exception('Invalid login');
48: }
49: return $this->execute('GET', '/servers/%s/players/', array($login));
50: }
51:
52: /**
53: * Return the number of persons that have favorited the server
54: * @param string $login
55: * @return int
56: * @throws Exception
57: */
58: function getFavoritedCount($login)
59: {
60: if(!$login)
61: {
62: throw new Exception('Invalid login');
63: }
64: return $this->execute('GET', '/servers/%s/favorited/', array($login));
65: }
66:
67: /**
68: * Return the report abuses created on the given login
69: * @param string $login
70: * @return object[]
71: * @throws Exception
72: */
73: function getReportAbuses($login)
74: {
75: if(!$login)
76: {
77: throw new Exception('Invalid login');
78: }
79: return $this->execute('GET', '/report-abuse/list/%s/', array($login));
80: }
81:
82: /**
83: * @param array[] $filters This should be an associative array, it can contain any of the following values with the
84: * correct key:
85: * environment string Canyon or Storm
86: * title string the Title idString
87: * playersMin int Minimum number of player connected on the server
88: * playersMax int Maximum number of player connected on the server
89: * hideFull bool If true, full servers will not be displayed
90: * visibility string It can take one of those 3 values: all, public or private
91: * zone string The path to a zone, for example: World|France. It will display every server in France subzones
92: * mode mixed it can be one of class constant, or directly the game mode name itself (TimeAttack, Melee, ...)
93: * ladderLimitMin int Ladder server limit min (ie: 70000)
94: * ladderLimitMax int Ladder server limit max (ie: 100000)
95: * offset int The offset in the list where the results will start
96: * length int Number of elements returned
97: * @return object[]
98: */
99: function getFilteredList(array $filters = array())
100: {
101: $params = http_build_query($filters, '', '&');
102: return $this->execute('GET', '/servers/?'.$params);
103: }
104:
105: }
106:
107: ?>
108: