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: 142 $:
10: * @date $Date: 2012-08-03 12:26:35 +0200 (ven., 03 août 2012) $:
11: */
12:
13: namespace Maniaplanet\WebServices;
14:
15: class ManiaFlash extends HTTPClient
16: {
17: /**
18: * Return informations about a ManiaFlash
19: * @param string $id
20: * @return Object
21: * - name
22: * - description
23: * - id
24: * @throws Exception
25: */
26: public function getChannel($id)
27: {
28: if(!$id)
29: {
30: throw new Exception('Invalid login');
31: }
32: return $this->execute('GET', '/maniaflash/channels/%s/', array($id));
33: }
34:
35: /**
36: * Return latest messages of a channel
37: * @param string $id
38: * @return Object[]
39: * - id
40: * - author
41: * - dateCreated
42: * - message
43: * - link
44: * @throws Exception
45: */
46: public function getMessages($id, $offset = 0, $length = 10)
47: {
48: if(!$id)
49: {
50: throw new Exception('Invalid login');
51: }
52: return $this->execute('GET', '/maniaflash/channels/%s/messages/?offset=%d&length=%d', array($id, $offset, $length));
53: }
54:
55: /**
56: * Publish a message on a maniaflash channel
57: * @param string $channelId
58: * @param string $message
59: * @param string $link
60: * @param string $iconStyle
61: * @param string $iconSubStyle
62: * @return type
63: */
64: public function postMessage($channelId, $message, $link = null, $iconStyle = null, $iconSubStyle = null)
65: {
66: return $this->execute('POST', '/maniaflash/channels/%s/', array(
67: $channelId,
68: array(
69: 'message' => $message,
70: 'link' => $link,
71: 'iconStyle' => $iconStyle,
72: 'iconSubStyle' => $iconSubStyle)));
73: }
74: }