From 6338bc3037177ff0a50e9d872ed9c61ecf122ed3 Mon Sep 17 00:00:00 2001 From: artin1982 <124486496+artin1982@users.noreply.github.com> Date: Tue, 16 May 2023 21:47:20 +0330 Subject: [PATCH 1/3] Add Support of PageToken while requesting comments Add Support of PageToken while requesting comments --- src/Youtube.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Youtube.php b/src/Youtube.php index 8ed490e..0c3dfd3 100644 --- a/src/Youtube.php +++ b/src/Youtube.php @@ -132,12 +132,13 @@ public function getCategories($regionCode = 'US', $part = ['snippet']) * @param string $order Specifies the order in which the API response should list comment threads. Valid values are: time, relevance. * @param array $part Specifies a list of one or more commentThread resource properties that the API response will include. * @param bool $pageInfo Add page info to returned array. + * @param string $pageToken The pageToken parameter identifies a specific page in the result set that should be returned. * @return array * @throws \Exception */ - public function getCommentThreadsByVideoId($videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false) { + public function getCommentThreadsByVideoId($videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false), $pageToken = null { - return $this->getCommentThreads(null, null, $videoId, $maxResults, $order, $part, $pageInfo); + return $this->getCommentThreads(null, null, $videoId, $maxResults, $order, $part, $pageInfo, $pageToken); } /** @@ -148,10 +149,11 @@ public function getCommentThreadsByVideoId($videoId = null, $maxResults = 20, $o * @param string $order Specifies the order in which the API response should list comment threads. Valid values are: time, relevance. * @param array $part Specifies a list of one or more commentThread resource properties that the API response will include. * @param bool $pageInfo Add page info to returned array. + * @param string $pageToken The pageToken parameter identifies a specific page in the result set that should be returned. * @return array * @throws \Exception */ - public function getCommentThreads($channelId = null, $id = null, $videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false) + public function getCommentThreads($channelId = null, $id = null, $videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false, $pageToken) { $API_URL = $this->getApi('commentThreads.list'); @@ -162,6 +164,7 @@ public function getCommentThreads($channelId = null, $id = null, $videoId = null 'maxResults' => $maxResults, 'part' => implode(',', $part), 'order' => $order, + 'pageToken' => $pageToken, ]); $apiData = $this->api_get($API_URL, $params); From d375e8066c1540c155e899fa9e1e80cea027547a Mon Sep 17 00:00:00 2001 From: artin1982 <124486496+artin1982@users.noreply.github.com> Date: Tue, 16 May 2023 22:20:20 +0330 Subject: [PATCH 2/3] Set pageToken default to null on getCommentThreads Function --- src/Youtube.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Youtube.php b/src/Youtube.php index 0c3dfd3..8f8ce48 100644 --- a/src/Youtube.php +++ b/src/Youtube.php @@ -153,7 +153,7 @@ public function getCommentThreadsByVideoId($videoId = null, $maxResults = 20, $o * @return array * @throws \Exception */ - public function getCommentThreads($channelId = null, $id = null, $videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false, $pageToken) + public function getCommentThreads($channelId = null, $id = null, $videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false, $pageToken = null) { $API_URL = $this->getApi('commentThreads.list'); From 7479770ece6591aafd9e5b9d0492b2787850d685 Mon Sep 17 00:00:00 2001 From: artin1982 <124486496+artin1982@users.noreply.github.com> Date: Wed, 17 May 2023 13:31:33 +0330 Subject: [PATCH 3/3] typo fixed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit my fault 🤦‍♂️ --- src/Youtube.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Youtube.php b/src/Youtube.php index 8f8ce48..08b44cc 100644 --- a/src/Youtube.php +++ b/src/Youtube.php @@ -136,7 +136,7 @@ public function getCategories($regionCode = 'US', $part = ['snippet']) * @return array * @throws \Exception */ - public function getCommentThreadsByVideoId($videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false), $pageToken = null { + public function getCommentThreadsByVideoId($videoId = null, $maxResults = 20, $order = null, $part = ['id', 'replies', 'snippet'], $pageInfo = false, $pageToken = null) { return $this->getCommentThreads(null, null, $videoId, $maxResults, $order, $part, $pageInfo, $pageToken); }