Alaouy\Youtube\Youtube::getChannelById PHP Method

getChannelById() public method

public getChannelById ( $id, $optionalParams = false, $part = ['id', 'snippet', 'contentDetails', 'statistics', 'invideoPromotion'] ) : StdClass
$id
return StdClass
    public function getChannelById($id, $optionalParams = false, $part = ['id', 'snippet', 'contentDetails', 'statistics', 'invideoPromotion'])
    {
        $API_URL = $this->getApi('channels.list');
        $params = array('id' => $id, 'part' => implode(', ', $part));
        if ($optionalParams) {
            $params = array_merge($params, $optionalParams);
        }
        $apiData = $this->api_get($API_URL, $params);
        return $this->decodeSingle($apiData);
    }

Usage Example

コード例 #1
0
 public function testGetChannelById()
 {
     $channelId = 'UCk1SpWNzOs4MYmr0uICEntg';
     $response = $this->youtube->getChannelById($channelId);
     $this->assertEquals('youtube#channel', $response->kind);
     $this->assertEquals($channelId, $response->id);
     $this->assertObjectHasAttribute('snippet', $response);
     $this->assertObjectHasAttribute('contentDetails', $response);
     $this->assertObjectHasAttribute('statistics', $response);
 }