Skip to content

Commit

Permalink
Fix 500 error in getChannelById and getChannelByName, removed topicDe…
Browse files Browse the repository at this point in the history
…tails from returned object
  • Loading branch information
madcoda committed Jul 7, 2014
1 parent dd9e82a commit b4d8883
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 10 additions & 4 deletions lib/Madcoda/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions test/Madcoda/Tests/YoutubeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit b4d8883

Please sign in to comment.