PHP/Youtube Code Needed

I need a working piece of php and I can’t make it myself. As a hobbyist web designer, my skill set just isn’t there. All it’s supposed to do is push a YouTube video through a javascript video player. I know it’s a bit more complicated that that, but from my attempts to research it doesn’t appear to be an exceptionally long piece of code I’m looking for - maybe a few lines.

My video pages problems …

On the page; arisenfromnothing (dot) com (slash) a (slash) videos
You’ll find in the html code your standard webpage stuff
it’s not the most modern code, but it works on all browsers and looks pretty cool.

The central div on the page executes a youtube call out:

Then associates a script (via the videos2 div id). The script is listed below:

// Video Player

function requestAccess (client, access_key) {
naturalsyntheticaccess.embedAccessKey(client + access_key + (access?1:0), ‘client’, ‘key1’, ‘key2’, ‘key3’, false, false, {getAccess: ‘true’});

function loadVideo(playerUrl, autoplay) {
playerUrl + ‘&rel=1&border=0&fs=1&autoplay=’ +
(autoplay?1:0), ‘player’, ‘465’, ‘344’, ‘9.0.0’, false,
false, {allowfullscreen: ‘true’});

function showMyVideos2(data) {
var feed = data.feed;
var entries = feed.entry || [];
var html = [’

    for (var i = 0; i < entries.length; i++) {
    var entry = entries[i];
    var title = entry.title.$t.substr(0, 50);
    var alt = entry.title.$t.substr(0, 500);
    var postday = entry.published.$t.substr(8, 2);
    var postmonth = entry.published.$t.substr(5, 2);
    var postyear = entry.published.$t.substr(0, 4);
    var content = entries[i].media$$description.$t.substr(0, 500);
    var thumbnailUrl = entries[i].media$$thumbnail[0].url;
    var playerUrl = entries[i].media$$content[0].url;
    var video = entries[i].media$$thumbnail[0].url.substr(22, 11);
    <a href=’, video, ’ rel=“lyteframe[video]” title="’, alt, ‘" rev=“width: 790px; height: 475px; scrolling: no;”>', alt, ' ’, alt, ‘
    Posted On: ‘,postmonth,’/’,postday,’/’,postyear,‘

    ’, content , ‘

    Watch This Video On YouTube
    <a href=’, video, ’ rel=“lyteframe[video]” title=“Click Here To Play This Video” rev=“width: 790px; height: 475px; scrolling: no;”>Play

document.getElementById(‘videos2’).innerHTML = html.join(’’);
if (entries.length > 0) {
loadVideo(entries[0].media$$content[0].url, false);

This scripts reaches out to a PHP file,and that’s where the trouble is. I don’t have the PHP, and don’t know how to write it. Here is the HTML portion of the file minus the needed PHP:

Video Player <?php HELP ---------------------------------------------------------------------------------------------------------------------------------------- If someone would be willing to write these couple of lines for me, I would be more than a little grateful. This has been the bane of my existence since I've begun trying to repair this page. Thanks

Reading through your code and looking at the site - nice site by the way :wink: - I see that the javascript is calling a page called video.php and passing in parameters. The video is passed like so:’, video, ’
(’ video ’ being a javascript variable.)

To pick this up with php you do this:

to avoid errors when there is nothing set in the url, do this:
[php]if(isset($_GET[‘watch’])) { // is watch set?
$watch = $_GET[‘watch’];

now, in your video.php page, change this parameter:

to this:
[php] // <?= is shorthand for <?php echo :wink: [/php]

This should get you going, let me know how you get on.
Red :wink:

Thanks for trying to help, I really appreciate it. I’m sure it can be frustrating to help people that don’t really know what they are doing.

I replaced the param line.

I don’t know what to do with the $_get part, I’m gathering it goes into the js file, I just don’t know where

On a side note,

Here’s the weirdest part of the whole project. I got up this morning, before reading your responses, and opened the existing video.php file and deleted some bits… and it worked! I was watching videos!

Then I went back into the file and copied the two lines of php so I could save it - at which time I can only assume I errantly changed something - and when I went back to the video page, it didn’t work.


I am assuming this code you posted is video.php ?
I have made the additions bold type so you can see them :wink:

Video Player <?php [b]if(isset($_GET['watch'])) { $watch = $_GET['watch']; } else { $watch = ''; // to stop errors below.. }[/b] ?>

Thank you!! So much! It works!!! Please send me an email at [email protected], I’d love to send you some free t-shirts, cd’s and such! Thanks!

Email sent, happy to help :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service