https://gdata.youtube.com/feeds/api/users/EXAMPLE/uploads?v=2&alt=jsonc的file_get_contents(“YOUTUBE API”)缓存/回报未更新/旧信息
当访问这个URL从浏览器直接,它会返回正确数据的时间100%。如果视频已添加,则视频已删除,视频已删除。
通过file_get_contents('https://gdata.youtube.com/feeds/api/users/EXAMPLE/uploads?v=2 & alt = jsonc')获取此数据时;
的数据似乎被缓存或不更新/电流数据...
如果继续刷新页面,它会显示/隐藏新视频,以及显示/隐藏删除的视频约5 10分钟,那将是准确的。
同样的事情,当我使用$ .getJSON(),或$。阿贾克斯()数据恰好...
不该数据相同的浏览器访问URL时为?
我只是试图获取用户上传的最新视频“示例”。
public function ajaxUpdateVideoFeed()
{
header("Content-type: application/json");
$json = file_get_contents('https://gdata.youtube.com/feeds/api/users/EXAMPLE/uploads?v=2&alt=jsonc');
$data = json_decode($json, TRUE);
$videoId = $data['data']['items'][0]['id'];
echo json_encode($videoId);die();
}
大通,我试着添加一个rand(),到url调用的结尾,它没有解决问题。谢谢回复。 – user1905188