alaouy / YouTube

🔥 Laravel PHP Facade/Wrapper for the Youtube Data API
MIT License
780 stars 205 forks source link

Add Get Channel By Handle #190

Closed j33tmane closed 3 months ago

j33tmane commented 8 months ago

Copy this function inside your YouTub.php to search channel by there handle name

public function getChannelByHandle($handleName, $optionalParams = [], $part = ['id', 'snippet', 'contentDetails', 'statistics'])
    {
        $API_URL = $this->getApi('channels.list');
        $params = [
            'forHandle' => $handleName,
            'part' => implode(',', $part),
        ];

        $params = array_merge($params, $optionalParams);

        $apiData = $this->api_get($API_URL, $params);

        return $this->decodeSingle($apiData);
    }
alaouy commented 8 months ago

@j33tmane if you found this method useful you can add it to the project, PRs are always welcome ;)

alaouy commented 3 months ago

This has been added to the package. Thank you both for your contribution 💯