Skip to content

Commit fe0ccb4

Browse files
author
cp6
committed
Added pagination topstreams
Added pagination for get top streams
1 parent 0109223 commit fe0ccb4

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

twitch-class.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,33 @@ public function apiCall($url, $params = array(), $method = 'get')
7272

7373
/**
7474
* Returns popular current streams
75+
* @param string $pagination
7576
* @param int $amount
7677
* @return string
7778
*/
78-
public function getTopStreams($amount = 25)
79+
public function getTopStreams($pagination = null, $amount = 25)
7980
{
80-
return $this->apiCall('/helix/streams?amount=' . rawurlencode($amount));
81+
if ($pagination == '') {
82+
return $this->apiCall('/helix/streams?first=' . rawurlencode($amount) . '');
83+
} else {
84+
return $this->apiCall('/helix/streams?first=' . rawurlencode($amount) . '&after=' . rawurlencode($pagination));
85+
}
8186
}
8287

8388
/**
8489
* Returns popular current streams for game id
8590
* @param int $game_id
91+
* @param string $pagination
8692
* @param int $amount
8793
* @return string
8894
*/
89-
public function getGameTopStreams($game_id, $amount = 25)
95+
public function getGameTopStreams($game_id, $pagination = null, $amount = 25)
9096
{
91-
return $this->apiCall('/helix/streams?game_id=' . rawurlencode($game_id) . '&amount=' . rawurlencode($amount));
97+
if ($pagination == '') {
98+
return $this->apiCall('/helix/streams?game_id=' . rawurlencode($game_id) . '&first=' . rawurlencode($amount));
99+
} else {
100+
return $this->apiCall('/helix/streams?game_id=' . rawurlencode($game_id) . '&first=' . rawurlencode($amount) . '&after=' . rawurlencode($pagination));
101+
}
92102
}
93103

94104
/**
@@ -116,14 +126,15 @@ public function getTopViewersForGame()
116126
/**
117127
* Returns top games being streamed
118128
* @param string $pagination
129+
* @param int $amount
119130
* @return string
120131
*/
121-
public function getTopGames($pagination = '')
132+
public function getTopGames($pagination = null, $amount = 25)
122133
{
123134
if ($pagination == '') {
124-
return $this->apiCall('/helix/games/top?first=25');
135+
return $this->apiCall('/helix/games/top?first=' . rawurlencode($amount) . '');
125136
} else {
126-
return $this->apiCall('/helix/games/top?first=25&after=' . rawurlencode($pagination));
137+
return $this->apiCall('/helix/games/top?first=' . rawurlencode($amount) . '&after=' . rawurlencode($pagination));
127138
}
128139
}
129140

0 commit comments

Comments
 (0)