Last week we re-designed the video Channel page of the site prositeweb.ca
. For that, we have written a PHP code using Google API Youtube
. The code allowed us to display videos from our YouTube channels on our website. And update the content automatically. In order words, every time we will add a video on Youtube, our website will be updated. We avoided the use of iFrames to reduce the load time and performance issues. If you want to know how we achieved that, read this article.
1 - Create your Youtube API key and get the YouTube Channel ID
Create your YouTube API key
You must have the API key to sync your website with Youtube. To obtain the API key, follow the following steps:
When you would have clicked on activate, the platform would generate a code (API) that you can use in the second part.
Get Youtube Channel ID
In order to retrieve the identifier of your Youtube channel, you should:
- Sign in to your YouTube account where your channel is,
- Then In the right corner at the top of the page, click on setting
- In the left menu, click Advanced Settings
- You will find your ID among the list of other information on the page
2 - Use the code below to display all your videos on the video Channel page
Code Explanation for video Channel:
Lines 1 and 2 of the code allow you to add your API key and YouTube ID respectively. Then line 7 (myQuery) retrieves videos from your Youtube account using your API key and ID. All that follows are just codes to retrieve videos' data. The result of this program is the video Channel page (see Screenshot).
The code does not include the design. In fact, with the API, you can format the content as you wish.
Thank you for taking the time to read the article. You can leave your comments and I would be happy to answer you. If you need help setting up a video page on your site, do not hesitate to contact us