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