1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace jofner\SDK\TwitchTV\Methods; |
4
|
|
|
|
5
|
|
|
use jofner\SDK\TwitchTV\TwitchRequest; |
6
|
|
|
use jofner\SDK\TwitchTV\TwitchSDKException; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Streams method class for TwitchTV API SDK for PHP |
10
|
|
|
* |
11
|
|
|
* @author Josef Ohnheiser <[email protected]> |
12
|
|
|
* @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
13
|
|
|
* @homepage https://github.com/jofner/Twitch-SDK |
14
|
|
|
*/ |
15
|
|
View Code Duplication |
class Stream |
16
|
|
|
{ |
17
|
|
|
/** @var TwitchRequest */ |
18
|
|
|
protected $request; |
19
|
|
|
|
20
|
|
|
const URI_STREAM = 'streams/'; |
21
|
|
|
const URI_STREAMS = 'streams'; |
22
|
|
|
const URI_STREAMS_FEATURED = 'streams/featured'; |
23
|
|
|
const URI_STREAM_SUMMARY = 'streams/summary'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Stream constructor |
27
|
|
|
* @param TwitchRequest $request |
28
|
|
|
*/ |
29
|
|
|
public function __construct(TwitchRequest $request) |
30
|
|
|
{ |
31
|
|
|
$this->request = $request; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get the specified channel's stream |
36
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamschannel |
37
|
|
|
* @param string $channel |
38
|
|
|
* @return \stdClass |
39
|
|
|
* @throws TwitchSDKException |
40
|
|
|
*/ |
41
|
|
|
public function getStream($channel) |
42
|
|
|
{ |
43
|
|
|
return $this->request->request(self::URI_STREAM . $channel); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns a list of streams |
48
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streams |
49
|
|
|
* @param string $queryString |
50
|
|
|
* @return \stdClass |
51
|
|
|
* @throws TwitchSDKException |
52
|
|
|
*/ |
53
|
|
|
public function getStreams($queryString) |
54
|
|
|
{ |
55
|
|
|
return $this->request->request(self::URI_STREAMS . $queryString); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Returns a list of featured (promoted) stream |
60
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamsfeatured |
61
|
|
|
* @param string $queryString |
62
|
|
|
* @return \stdClass |
63
|
|
|
* @throws TwitchSDKException |
64
|
|
|
*/ |
65
|
|
|
public function getFeatured($queryString) |
66
|
|
|
{ |
67
|
|
|
return $this->request->request(self::URI_STREAMS_FEATURED . $queryString); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Returns a summary of current streams |
72
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamssummary |
73
|
|
|
* @param string $queryString |
74
|
|
|
* @return \stdClass |
75
|
|
|
* @throws TwitchSDKException |
76
|
|
|
*/ |
77
|
|
|
public function getSummary($queryString) |
78
|
|
|
{ |
79
|
|
|
return $this->request->request(self::URI_STREAM_SUMMARY . $queryString); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|