From b4d888316974012c5d98d85bf4bca1c6fe06b8be Mon Sep 17 00:00:00 2001 From: Jason Leung Date: Mon, 7 Jul 2014 12:59:39 +0800 Subject: [PATCH] Fix 500 error in getChannelById and getChannelByName, removed topicDetails from returned object --- lib/Madcoda/Youtube.php | 14 ++++++++++---- test/Madcoda/Tests/YoutubeTest.php | 2 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Madcoda/Youtube.php b/lib/Madcoda/Youtube.php index 5080aa8..3aa8a58 100644 --- a/lib/Madcoda/Youtube.php +++ b/lib/Madcoda/Youtube.php @@ -150,13 +150,16 @@ public function searchAdvanced($params) * @return \StdClass * @throws \Exception */ - public function getChannelByName($username) + public function getChannelByName($username, $optionalParams = false) { $API_URL = $this->getApi('channels.list'); $params = array( 'forUsername' => $username, - 'part' => 'id,snippet,contentDetails, statistics,topicDetails,invideoPromotion' + 'part' => 'id,snippet,contentDetails,statistics,invideoPromotion' ); + if($optionalParams){ + $params = array_merge($params, $optionalParams); + } $apiData = $this->api_get($API_URL, $params); return $this->decodeSingle($apiData); } @@ -166,13 +169,16 @@ public function getChannelByName($username) * @return \StdClass * @throws \Exception */ - public function getChannelById($id) + public function getChannelById($id, $optionalParams = false) { $API_URL = $this->getApi('channels.list'); $params = array( 'id' => $id, - 'part' => 'id,snippet,contentDetails, statistics,topicDetails,invideoPromotion' + 'part' => 'id,snippet,contentDetails,statistics,invideoPromotion' ); + if($optionalParams){ + $params = array_merge($params, $optionalParams); + } $apiData = $this->api_get($API_URL, $params); return $this->decodeSingle($apiData); } diff --git a/test/Madcoda/Tests/YoutubeTest.php b/test/Madcoda/Tests/YoutubeTest.php index 6df6bc7..afb7882 100644 --- a/test/Madcoda/Tests/YoutubeTest.php +++ b/test/Madcoda/Tests/YoutubeTest.php @@ -125,7 +125,6 @@ public function testGetChannelByName() $this->assertObjectHasAttribute('snippet', $response); $this->assertObjectHasAttribute('contentDetails', $response); $this->assertObjectHasAttribute('statistics', $response); - $this->assertObjectHasAttribute('topicDetails', $response); } public function testGetChannelById() @@ -138,7 +137,6 @@ public function testGetChannelById() $this->assertObjectHasAttribute('snippet', $response); $this->assertObjectHasAttribute('contentDetails', $response); $this->assertObjectHasAttribute('statistics', $response); - $this->assertObjectHasAttribute('topicDetails', $response); } public function testGetPlaylistsByChannelId()