doudi8298 2015-03-22 22:43
浏览 63
已采纳

Google Shortener API:白名单IP无效

I have a Google Shortener API credential setup on Developers Console. I have a Public API access created for a key, with the allowed IP of 199.180.250.40.

But when I call the API, I get this Google error:

There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.

I made sure my server is 199.180.250.40, and the script is running off that server. I've triple checked, including visiting whatismyip using lynx.

I'm using this code: https://github.com/sebi/googl-php

With this code:

        $googl = new Googl("my-key");
        $short = $googl->shorten($url);
        unset($googl);

Why is it rejecting even though that is my servers exact IP?

I don't send userIp but Google says:

If the userIp parameter is missing, your machine's IP address will be used instead.

Are there any access logs available on Google's side I can review?

  • 写回答

1条回答 默认 最新

  • dongyi0114 2015-03-27 14:12
    关注

    As mentioned in the comments, the server was using IPv6 and thus didn't match the IPv4 I entered. I entered my IPv6, and it worked.

    There was also a "requests per second limit" set to 5 or so. This was a bit low, so I had move it up to 30.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?