Alaouy\Youtube\Youtube::searchChannelVideos PHP Method

searchChannelVideos() public method

Search only videos in the channel
public searchChannelVideos ( string $q, string $channelId, integer $maxResults = 10, string $order = null, $part = ['id', 'snippet'], $pageInfo = false ) : object
$q string
$channelId string
$maxResults integer
$order string
$pageInfo
return object
    public function searchChannelVideos($q, $channelId, $maxResults = 10, $order = null, $part = ['id', 'snippet'], $pageInfo = false)
    {
        $params = array('q' => $q, 'type' => 'video', 'channelId' => $channelId, 'part' => implode(', ', $part), 'maxResults' => $maxResults);
        if (!empty($order)) {
            $params['order'] = $order;
        }
        return $this->searchAdvanced($params, $pageInfo);
    }

Usage Example

 public function testSearchChannelVideos()
 {
     $limit = rand(3, 10);
     $response = $this->youtube->searchChannelVideos('Android', 'UCVHFbqXqoYvEWM1Ddxl0QDg', $limit);
     $this->assertEquals($limit, count($response));
     $this->assertEquals('youtube#searchResult', $response[0]->kind);
     $this->assertEquals('youtube#video', $response[0]->id->kind);
 }