1

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

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

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

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

4

1 回答 1

1

I had the same issue and finally i decided to add a hash column to the DB so I can know if something has changed.

Something like:

$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
} 
于 2014-01-12T18:31:11.630 回答