Google URLShortener API returns ipRefererBlocked

后端 未结 2 951
旧时难觅i
旧时难觅i 2021-01-14 03:06

I\'m trying to use the Google URL shortener API with PHP:

$apiKey = \'ABC\';
$url = \'http://www.stackoverflow.com/\';

$postData = array(\'longUrl\' => $         


        
相关标签:
2条回答
  • 2021-01-14 03:28

    I'll just add to this that I had a similar issue when using a Google API from a Rackspace cloud server. If ANY IP addresses are added, then it will always be blocked (checked multiple times to ensure it was the correct IP, including making requests from server to a page that reported the remote IP). So from Rackspace cloud hosts, I have to allow any IP. If I'm hosting anywhere else, then the IP restrictions work as designed.

    0 讨论(0)
  • 2021-01-14 03:29

    This is an app settings issue in the Google Developers Console. On the credentials screen it lists the IPs that are allowed to use the API Key. It's a security precaution to help protect the key if it leaks.

    enter image description here

    You need to edit allowed IPs to either be empty (less secure) or update it to include the actual IP of your server.

    enter image description here

    0 讨论(0)
提交回复
热议问题