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: 170 $:
10: * @date $Date: 2012-10-16 11:22:12 +0200 (mar., 16 oct. 2012) $:
11: */
12:
13: namespace Maniaplanet\WebServices\ManiaConnect;
14:
15: /**
16: * The base class for using OAuth2.
17: */
18: class Player extends Client
19: {
20:
21: /**
22: * This is the first method to call when you have an authorization code.
23: * It will retrieve an access token if possible and then call the service to
24: * retrieve a basic object about the authentified player.
25: *
26: * You do not need any special scope to call this service, as long as you
27: * have an access token.
28: *
29: * If an access token is not found, it will return false
30: *
31: * @return object A player object or false if no access token is found
32: */
33: function getPlayer()
34: {
35: $player = self::$persistance->getVariable('player');
36: if(!$player)
37: {
38: if($this->getAccessToken())
39: {
40: $player = $this->executeOAuth2('GET', '/player/');
41: self::$persistance->setVariable('player', $player);
42: }
43: }
44: return $player;
45: }
46:
47: /**
48: * Returns an object containing the online status and the dedicated server
49: * info on which the player is playing, if applicable.
50: *
51: * Scope needed: online_status
52: *
53: * @return object
54: */
55: function getOnlineStatus()
56: {
57: return $this->executeOAuth2('GET', '/player/status/');
58: }
59:
60: /**
61: * Returns the email associated with the player's account.
62: *
63: * Scope needed: email
64: *
65: * @return string
66: */
67: function getEmail()
68: {
69: return $this->executeOAuth2('GET', '/player/email/');
70: }
71:
72: /**
73: * Returns the buddies of the player as an array of player objects
74: *
75: * Scope needed: buddies
76: *
77: * @return array[object]
78: */
79: function getBuddies()
80: {
81: return $this->executeOAuth2('GET', '/player/buddies/');
82: }
83:
84: /**
85: * Gets the list of the player's registered dedicated servers and their
86: * online statuses.
87: *
88: * Scope needed: dedicated
89: *
90: * @return array[object]
91: */
92: function getDedicated()
93: {
94: return $this->executeOAuth2('GET', '/player/dedicated/');
95: }
96:
97: /**
98: * Gets the list of server loing's report abuses
99: *
100: * Scope needed: dedicated
101: *
102: * @return array[object]
103: */
104: function getReportAbuses($serverLogin)
105: {
106: return $this->executeOAuth2('GET', '/player/dedicated/%s/reportAbuse/',array($serverLogin));
107: }
108:
109: /**
110: * Gets the list of the player's registered Manialinks.
111: *
112: * Scope needed: manialinks
113: *
114: * @return array[object]
115: */
116: function getManialinks()
117: {
118: return $this->executeOAuth2('GET', '/player/manialinks/');
119: }
120:
121: /**
122: * Get the player's list of contracts team
123: *
124: * scope needed : teams
125: *
126: * @return array[object]
127: */
128: function getContracts()
129: {
130: return $this->executeOAuth2('GET', '/player/contracts/');
131: }
132:
133: /**
134: * Get team's whose player is admin
135: *
136: * scope needed : teams
137: *
138: * @return array[object]
139: */
140: function getTeams()
141: {
142: return $this->executeOAuth2('GET', '/player/teams/');
143: }
144:
145: /**
146: * scope needed : titles
147: */
148: function getOwnedTitles()
149: {
150: return $this->executeOAuth2('GET', '/player/titles/owned/');
151: }
152:
153: /**
154: * scope needed : titles
155: */
156: function getInstalledTitles()
157: {
158: return $this->executeOAuth2('GET', '/player/titles/installed/');
159: }
160:
161: }
162:
163: ?>