youtube api不会在php中播放一些视频

时间:2015-11-23 09:10:59

标签: php youtube youtube-api youtube-data-api

当我开始播放视频或来自“Vevo”或其他频道的某些视频时,我收到错误的原因是没有播放。它通过网络在localhost中正常工作,它会出错或不播放。

这是我的youtube api完整代码。

<?php


    $keyword = $movie_name .'movie songs';

    $keyword=preg_replace("/ /","+",$keyword);

    $response = file_get_contents("https://www.googleapis.com/youtube/v3/search?part=snippet&q={$keyword}&type=video&key=AIzaSyBQCHmQUDDjQ99UKLF9OkBktAL4K88iUa8&maxResults=7");

    $searchResponse = json_decode($response,true);
    foreach ($searchResponse['items'] as $searchResult) {
    $a = $searchResult['id']['videoId'];



    $b = preg_replace('/[^a-zA-Z0-9]/', '_', $searchResult['snippet']['title']);


    ?>
        <div id="<?php echo $a; ?>" draggable="true" ondragstart="drag(event)" class="videoItemContainer" onClick="playThis('<?php echo $a; ?>', '<?php echo $b; ?>')"> 


    <a href='#'>


       <img src="<?php echo $searchResult['snippet']['thumbnails']['medium']['url']; ?>" style="height:200px; width:270px;" alt="Loading please wait...">

       <div style="font-size:14px; margin-top:10px;margin-bottom:60px;"> 

       <?php echo $searchResult['snippet']['title']; ?>

        </div>

    </a>

        </div>

        <?php } ?> 

0 个答案:

没有答案
相关问题