Skip to content

Commit b4d8883

Browse files
committed
Fix 500 error in getChannelById and getChannelByName, removed topicDetails from returned object
1 parent dd9e82a commit b4d8883

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/Madcoda/Youtube.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,16 @@ public function searchAdvanced($params)
150150
* @return \StdClass
151151
* @throws \Exception
152152
*/
153-
public function getChannelByName($username)
153+
public function getChannelByName($username, $optionalParams = false)
154154
{
155155
$API_URL = $this->getApi('channels.list');
156156
$params = array(
157157
'forUsername' => $username,
158-
'part' => 'id,snippet,contentDetails, statistics,topicDetails,invideoPromotion'
158+
'part' => 'id,snippet,contentDetails,statistics,invideoPromotion'
159159
);
160+
if($optionalParams){
161+
$params = array_merge($params, $optionalParams);
162+
}
160163
$apiData = $this->api_get($API_URL, $params);
161164
return $this->decodeSingle($apiData);
162165
}
@@ -166,13 +169,16 @@ public function getChannelByName($username)
166169
* @return \StdClass
167170
* @throws \Exception
168171
*/
169-
public function getChannelById($id)
172+
public function getChannelById($id, $optionalParams = false)
170173
{
171174
$API_URL = $this->getApi('channels.list');
172175
$params = array(
173176
'id' => $id,
174-
'part' => 'id,snippet,contentDetails, statistics,topicDetails,invideoPromotion'
177+
'part' => 'id,snippet,contentDetails,statistics,invideoPromotion'
175178
);
179+
if($optionalParams){
180+
$params = array_merge($params, $optionalParams);
181+
}
176182
$apiData = $this->api_get($API_URL, $params);
177183
return $this->decodeSingle($apiData);
178184
}

test/Madcoda/Tests/YoutubeTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public function testGetChannelByName()
125125
$this->assertObjectHasAttribute('snippet', $response);
126126
$this->assertObjectHasAttribute('contentDetails', $response);
127127
$this->assertObjectHasAttribute('statistics', $response);
128-
$this->assertObjectHasAttribute('topicDetails', $response);
129128
}
130129

131130
public function testGetChannelById()
@@ -138,7 +137,6 @@ public function testGetChannelById()
138137
$this->assertObjectHasAttribute('snippet', $response);
139138
$this->assertObjectHasAttribute('contentDetails', $response);
140139
$this->assertObjectHasAttribute('statistics', $response);
141-
$this->assertObjectHasAttribute('topicDetails', $response);
142140
}
143141

144142
public function testGetPlaylistsByChannelId()

0 commit comments

Comments
 (0)