Youtube JSON失败了

时间:2013-09-24 07:27:53

标签: json youtube-api

当我尝试从此网址获取JSON时:

http://gdata.youtube.com/feeds/api/users/user/favorites?v=2&alt=jsonc&max-results=1

我收到此消息:

{"apiVersion":"2.1","error":{"code":403,"message":"Not allowed.","errors":[{"domain":"GData","code":"ServiceForbiddenException","internalReason":"Not allowed."}]}}

有什么想法吗? 谢谢你的帮助。

更新:

我已将所有视频视为公开视频。这是我的真实网址: http://gdata.youtube.com/feeds/api/users/ptiundiksha/favorites?v=2&alt=jsonc&max-results=1

我也尝试上传频道,它只返回一个空数组。 http://gdata.youtube.com/feeds/api/users/ptiundiksha/uploads?v=2&alt=jsonc&max-results=1

2 个答案:

答案 0 :(得分:1)

我认为在该网址中显示user,您需要将其替换为有效的YouTube用户名。

答案 1 :(得分:1)

错误消息(代码“:403,”message“:”不允许。“),表示”用户“将其收藏夹列表保持为私有。仅当”用户“将其设为PUBLIC或者您是还提供access_token。

请注意,不推荐使用API​​ V2。

2013年9月25日更新: 当我尝试你的网址“http://gdata.youtube.com/feeds/api/users/ptiundiksha/favorites”时,结果是:“不允许。”这意味着您已将此列表设为私有。您可以通过取消选中https://www.youtube.com/my_favorites中的“将此列表设为私有”复选框(当您登录YouTube时)将此列表设置为PUBLIC。假设您的收藏夹列表中有一些视频也是公开的。

当我尝试你的网址“http://gdata.youtube.com/feeds/api/users/ptiundiksha/uploads?v=2&alt=json”时,我确实得到了一个结果。回复显示该列表中有56个视频。如果你得到一个空列表,你的代码可能会出错。