1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ritero\SDK\TwitchTV\Methods; |
4
|
|
|
|
5
|
|
|
use ritero\SDK\TwitchTV\TwitchException; |
6
|
|
|
use ritero\SDK\TwitchTV\TwitchRequest; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* TwitchTV API SDK for PHP |
10
|
|
|
* |
11
|
|
|
* Users method class |
12
|
|
|
* |
13
|
|
|
* @author Josef Ohnheiser <[email protected]> |
14
|
|
|
* @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
15
|
|
|
* @homepage https://github.com/jofner/Twitch-SDK |
16
|
|
|
*/ |
17
|
|
|
class User |
18
|
|
|
{ |
19
|
|
|
/** @var TwitchRequest */ |
20
|
|
|
protected $request; |
21
|
|
|
|
22
|
|
|
const URI_USER = 'users/'; |
23
|
|
|
const URI_USER_AUTH = 'user'; |
24
|
|
|
const URI_STREAMS_FOLLOWED_AUTH = 'streams/followed'; |
25
|
|
|
const URI_VIDEOS_FOLLOWED_AUTH = 'videos/followed'; |
26
|
|
|
|
27
|
|
|
public function __construct(TwitchRequest $request) |
28
|
|
|
{ |
29
|
|
|
$this->request = $request; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Get the specified user |
34
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-usersuser |
35
|
|
|
* @param $username |
36
|
|
|
* @return \stdClass |
37
|
|
|
* @throws TwitchException |
38
|
|
|
*/ |
39
|
|
|
public function getUser($username) |
40
|
|
|
{ |
41
|
|
|
$this->request->setApiVersion(3); |
42
|
|
|
|
43
|
|
|
return $this->request->request(self::URI_USER . $username); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get the authenticated user |
48
|
|
|
* - requires scope 'user_read' |
49
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-user |
50
|
|
|
* @param string |
51
|
|
|
* @return \stdClass |
52
|
|
|
* @throws TwitchException |
53
|
|
|
*/ |
54
|
|
|
public function getUserAuth($queryString) |
55
|
|
|
{ |
56
|
|
|
$this->request->setApiVersion(3); |
57
|
|
|
|
58
|
|
|
return $this->request->request(self::URI_USER_AUTH . $queryString); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* List the live streams that the authenticated user is following |
63
|
|
|
* - requires scope 'user_read' |
64
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-streamsfollowed |
65
|
|
|
* @param string $queryString |
66
|
|
|
* @return \stdClass |
67
|
|
|
* @throws TwitchException |
68
|
|
|
*/ |
69
|
|
|
public function getFollowedStreams($queryString) |
70
|
|
|
{ |
71
|
|
|
$this->request->setApiVersion(3); |
72
|
|
|
|
73
|
|
|
return $this->request->request(self::URI_STREAMS_FOLLOWED_AUTH . $queryString); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* List of videos that the authenticated user is following |
78
|
|
|
* - requires scope 'user_read' |
79
|
|
|
* @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-videosfollowed |
80
|
|
|
* @param $queryString |
81
|
|
|
* @return \stdClass |
82
|
|
|
* @throws TwitchException |
83
|
|
|
*/ |
84
|
|
|
public function getFollowedVideos($queryString) |
85
|
|
|
{ |
86
|
|
|
$this->request->setApiVersion(3); |
87
|
|
|
|
88
|
|
|
return $this->request->request(self::URI_VIDEOS_FOLLOWED_AUTH . $queryString); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|