Intereting Posts

API Google Contacts отвечает с ошибкой «countryBlock»

У меня есть приложение, которое импортирует контакты из Google Контактов. Приложение работало нормально, до сегодняшнего утра, когда мы изменили «владельца» API. Он был создан под моим личным аккаунтом для целей развития.

После настройки всего, Google начал отвечать на это:

Array ( [error] => Array ( [errors] => Array ( [0] => Array ( [domain] => global [reason] => countryBlocked [message] => This service is not available from your country ) ) [code] => 403 [message] => This service is not available from your country ) ) 

Это строка, которая генерирует ошибку, и объявление функций (они находятся в разных файлах):

 $xmlresponse = curl_file_get_contents($url); function curl_file_get_contents($url) { $curl = curl_init(); $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'; curl_setopt($curl, CURLOPT_URL, $url); //The URL to fetch. This can also be set when initializing a session with curl_init(). curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); //TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly. curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); //The number of seconds to wait while trying to connect. curl_setopt($curl, CURLOPT_USERAGENT, $userAgent); //The contents of the "User-Agent: " header to be used in a HTTP request. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); //To follow any "Location: " header that the server sends as part of the HTTP header. curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE); //To automatically set the Referer: field in requests where it follows a Location: redirect. curl_setopt($curl, CURLOPT_TIMEOUT, 10); //The maximum number of seconds to allow cURL functions to execute. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); //To stop cURL from verifying the peer's certificate. $contents = curl_exec($curl); curl_close($curl); return $contents; } 

Я пытался использовать другой IP-адрес: curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip")); и я прокомментировал строку агента пользователя. Однако не повезло.

Когда я запускаю его с моего localhost, он отлично работает без ошибок. Я в Южной Африке, и на сервере эта ошибка возникает, находится в Германии.

Я пробовал поиск в Google для политики Google, но не понял.

Может ли кто-нибудь объяснить, почему это происходит и как я могу обойти его?

Solutions Collecting From Web of "API Google Contacts отвечает с ошибкой «countryBlock»"

Эта ошибка указывает, что Google считает, что ваш IP-адрес принадлежит стране с ограниченным доступом . Однако Германия не является одной из этих стран, так что это, вероятно, ошибка. Пожалуйста, заполните следующую форму, чтобы исправить это: https://support.google.com/websearch/contact/ip

проверьте эту тему, которая похожа. В нем говорится, что проблема связана с обращением к центральному ядру Google API с помощью http: request (а не https 🙂

Intermittent 403 «Эта услуга недоступна в вашей стране» Ошибка для выполнения API