2010-01-09 61 views
4

我正在使用YouTube的API从YouTube的帐户(与 只是用户饲料...没有用户身份验证)在我们的网站上的内容。 由于昨天上午,我们不断收到:yt:配额太多最近的电话 - YouTube的API帮助

<error> 
    <domain>yt:quota</domain> 
    <code>too_many_recent_calls</code> 
</error> 

它开始了作为一个随机事件,但很快,我们得到这个错误的时间100%。 我尝试以下quota limits instructions,但我仍然得到错误:

If you are receiving quota errors, there are a couple steps you can take:

  • Have your requests include your developer key and clientID. I do this
  • Make sure the actions your code is performing is user-initiated. I do this
  • Pass the user's IP address in the restriction query parameter. I am able to pass only the proxy/server IP address, not the exact client's because Google AppEngine does not support InetAddress.getLocalHost().getHostAddress())
  • If you are requesting authenticated feeds, login as the user rather than a site-wide account. I am not using authentication
+0

更新:试过这个地方和一切工作完全无关的任何数量的YouTube的调用问题发生。 – Satish 2010-01-10 00:13:32

回答

6

我有与YouTube API +应用程序引擎同样的问题。我将开发人员密钥作为请求的参数,以及其他建议参数(请求url中的user-ip,developer-key)传递给App Engine,但仍然无法使用。

好像开发人员密钥没有通过(尽管X-Gdata-key存在于POST请求头文件中)。我发现这个解决方案:

每个YouTubeService实例具有属性Developer_Key开发CLIENT_ID。设置在创建服务实例时,该属性(而不是在头部或查询实例的关键属性设置的“X-的GData密钥”)使Developer_Key开发的应用程序ID:CLIENT_ID发送在每一个请求中,并被成功接受。

您可以在constructor of YouTubeService for the Java API中设置这些值。

如果您使用的Python API,您可以直接设置参数如下:

client = gdata.youtube.service.YouTubeService() 
    client.client_id = <application_id> 
    client.developer_key = <developer_key> 

我注意到Developer_Key开发并没有通过检查的YouTube API仪表盘的统计打通。

+0

@Javiefdr:只是说它对我很有用*到目前为止*,我下载了115K个条目,并且仍然在运行。之前,我在获得一个' 403禁止的回应。 – casperOne 2011-04-24 04:01:52

2

在用python重新构建youtube api的轮子时,我发现可能导致X-GData-Key无法识别的东西。这回答@Javierfdr。

简短回答:urllib2正在做.capitalize().title()全部和搞砸头。

urllib2模块中有很多这些代码。一些在处理程序和一些在RequestX-GData-Key被转换成X-Gdata-Key标题,请注意下d),或X-gdata-key(当大写)。我不得不建立一个自定义的HTTPSHandler和一个Request对象来注释掉这些行。

我不确定他们为什么要这样做,但是一个长长的线程在http://bugs.python.org/issue2275中讨论了这个问题。我想它并没有让它成为python 2.7。

我试用了requests library,它没有弄乱它与标题。万岁:)

只是为了让别人不会浪费他们的时间,或至少有线索发生了什么事情。

- 编辑 -

其实,我发现了RFC状态的头字段名称是区分大小写的,我无法找到任何证据证明谷歌没有。我看错了以下声明,我还没有得到任何统计:(对不起误导

After changing all of them, I finally saw the stats in YouTube API dashboard - always wondered why there was no data until now.