【问题标题】:Youtube API, check if a video has been modifiedYoutube API,检查视频是否被修改
【发布时间】:2013-02-08 05:42:44
【问题描述】:

我在我的 CMS 上使用 YouTube API 和 ZendGdata 库。

我检索成员的所有视频,并使用 cron 动态创建所有相关文章。

我需要知道成员是否修改了视频(标题、说明...),可能带有日期或其他内容。我可以检索所有数据并检查差异,但它不是很“轻”。

这个 API 中有这样的数据吗?谢谢!

【问题讨论】:

    标签: php api zend-framework youtube


    【解决方案1】:

    我遇到了同样的问题,最后我决定在数据库中添加一个哈希列,这样我就可以知道是否发生了变化。

    类似:

    $playlist['publishDate'] = $playlistJson['items'][0]['snippet']['publishedAt'];
    $playlist['youtubeId'] = $playlistJson['items'][0]['id'];
    $playlist['title'] = $playlistJson['items'][0]['snippet']['title'];
    //...
    
    $playlist['dataHash'] = md5(implode('--',$playlist));
    
    $youtubePlaylistId=$mysqli->real_escape_string($playlist['youtubeId']);
    
    $sResult=$mysqli->query("SELECT dataHash FROM channel WHERE youtubeId=$youtubePlaylistId LIMIT 1") or die($mysqli->error.__LINE__);
    
    if($sResult->num_rows == 1) {
        while ($sRow = $sResult->fetch_assoc()) {
            $currentDataHash =$sRow['dataHash'];
        }
        if ($currentDataHash==$playlist['dataHash']) {
            //playlist exists and data is identical
        } else {
            //playlist exists but data needs refresh
        }
    } else {
        //playlist does not exist
    } 
    

    【讨论】:

      猜你喜欢
      • 2015-08-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-11
      • 2015-10-08
      • 2016-02-26
      • 2020-07-11
      • 2012-10-08
      • 2016-11-18
      相关资源
      最近更新 更多