I am using Google Youtube API and YoutubeAnalytics API, I read on their documentation that you need a CHANNEL_ID
inorder for you to grab the user's videos.
I can now successfully Google authenticate the user in my application, I just wanted to ask if how can I get their CHANNEL_ID
after they authenticate.
I am using PHP, I've been searching over the net but can't seem to find any example how to do that.
Your help will be greatly appreciated!
Thanks! :)
Since you're using PHP, I'm assuming you're using the PHP-based gapi-client? Here's the call to make:
$listResponse = $youtube->channels->listChannels('id', array(
'mine' => 'true',
))
The 'id' part returns the ID of the channel, and by passing the parameter "mine" as true, you're telling the API to return the data for the authenticated user.
If you're using a different client or rolled your own, you can also just hit this endpoint (passing the oAuth access token you have in the header or as another parameter to the request):
GET https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&key={YOUR_API_KEY}