thank_you
thank_you

Reputation: 11097

YouTube embed and PHP

I allowed the user to upload a YouTube embed link that will display the video on their profile page. However, as my current code runs, it does not work. I echoed the field successfully from the database that holds the youtube embed link so I know the php code is working in terms of extracting the link. I then replace the PHP code and put the actual link in the src attribute but it still does not work. Here is the code below.

<iframe width="420" height="315"
    src="<?php echo $detailed_profile_data['video_1'];?>" 
    frameborder="1" allowfullscreen>
</iframe>

The function detailed_profile_data grabs the link the user submitted to the database.This is what it returns. youtu.be/yWk7FOnFvGs

Upvotes: 0

Views: 224

Answers (1)

uzyn
uzyn

Reputation: 6683

You might want to use oEmbed to find out the actual embeddable URL from the URL that user submits.

This Stack Overflow article might help: How can I retrieve YouTube video details from video URL using PHP?

Upvotes: 1

Related Questions