Google Youtube API

Hi all

I need to display some videos in a customised way using Yutube’s API. Should I use js to do this or php?

Are there any pros in using one over the other?


Define ‘customized way’. Specifically, does the customization need to change on the fly (during the same pageload)?

I need to display a video based on a variable passed into the url. I also want to disable the video player controls.

So nothing too complicated. Ive written some js which handles most of what I want to do, but I wonder whether I should do it in php so the js is hidden from the user.

I suppose having the code hidden from the user is one benefit of using php instead of js.

I’m… almost 100% sure that even if you do it in PHP, it will be visible to the user.

Hi @bolton, you can actually disable controls by just passing ?controls=0 to the iframe URL… no JS needed so far:

<iframe src=""></iframe>

And with dynamic video ID from the query string:

<iframe src="<?= $_GET['youtube-id'] ?>?controls=0"></iframe>

Hmm. Ive been fiddling about with Youtube API PHP. Ive now managed to get it to output json, which is good. But how do I now display that in html to the user?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.