Facebook应用程序不显示youtube嵌入视频

时间:2014-01-05 03:10:01

标签: php facebook iframe youtube

我想在我的Facebook应用程序上随机查看YouTube视频,但代码显示在下方,没有任何内容

我的代码:

<?php
    $num=rand(0,2); 
    $video=array("Z0xfWCDLoCU","vv7EtBmZ-ko","Lh3TokLzzmw");
?>

<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
    <title>Таны өнөөдрийн сонсох дуу</title>
</head>
<center>
  <body background="assets/1.jpg" >
</br>   
   <p style="font-size:30px"><?php echo $user_profile['name']; ?> Your song of the day </p>
</br>
</br>
   <p style="font-size:50px;color:#a7a7a7;"><?php echo $songs[$num]; ?> </p>

<?php echo "<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/$video[$num]\" frameborder=\"0\" ></iframe>"; ?>

  </body>
  </center>
</html>

,结果是

 <iframe width="560" height="315" src="http://www.youtube.com/embed/0k_1kvDh2UA" frameborder="0"></iframe>
       #document
         <html>
            <head></head>
            <body></body>
         </html>
        </iframe>   

1 个答案:

答案 0 :(得分:0)

试试这个,

<?php

$num=rand(0,2); 
$video=array("Z0xfWCDLoCU","vv7EtBmZ-ko","Lh3TokLzzmw");

echo "<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/$video[$num]\" frameborder=\"0\" ></iframe>"; 
?>

变量在php ...

之外声明