Google PageSpeed API范围的网址

时间:2015-08-11 11:22:23

标签: php oauth oauth-2.0 google-oauth google-pagespeed

我有基于oauth 2.0的用户在线工具。我可以访问他们的Google Analytics等。

我唯一无法访问的是PageSpeed API,因为我不知道并且无法找到此服务的范围网址。

对于谷歌分析,例如,我使用https://www.googleapis.com/auth/analytics.readonly范围等。但似乎PageSpeed api没有任何范围,只能使用用户API密钥访问。但在这种情况下,我无法向用户提供其页面的Pagespeed洞察(因为一个API密钥每天只有5万个查询)。

我甚至在Oauth游乐场找到了: https://developers.google.com/oauthplayground/

如果我不想将用户推向Google Developer Console,可以帮助我解决这个问题吗?

谢谢!

2 个答案:

答案 0 :(得分:1)

PageSpeed API access works fine with just an API key (as mentioned in the Google Developers Console, see the subpage there for the PageSpeed API) which is also much easier to implement for the developer.

I think this is the case because one can by default run pagespeed for any given URL, so no need for a permission workflow as opposed to Google Analytics etc.

答案 1 :(得分:1)

如上所述,它应该可以正常使用api调用。根据{{​​3}}。

这是API的 v2 的API网址: 'Google PageSpeed Insights API?'

当前版本是v4。所以看起来像这样:https://www.googleapis.com/pagespeedonline/v2/runPagespeed

这是使用v2调用Pagespeed API的示例函数:

OnMouseOver()

P.S:您需要API Key,您可以在Google Developers下生成,以便运行它。还包括以下包:(按照我上次检查):

  1. google python api client
  2. 要求
  3. 试试这个,你应该做得好。不需要 oauth。