谷歌联系人API与&QUOT响应; countryBlock"错误 [英] Google Contacts API responds with "countryBlock" error

查看:182
本文介绍了谷歌联系人API与&QUOT响应; countryBlock"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有进口的接触,从谷歌联系人的应用程序。该应用程序工作正常,直到今天早上,当我们改变了API所有者。它下设我的个人账户为发展宗旨。

I have an app that imports contacts from Google Contacts. The app worked fine, until this morning when we changed the API 'owner'. It was set up under my personal account for development purposes.

设置了一切后,谷歌开始使用此回应:

After setting up everything, Google started responding with this:

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
        )
)

这是产生错误的行和功能声明(它们在不同的文件):

This is the line that generates the error, and the functions declaration (they are in different files):

$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,阵列(REMOTE_ADDR:$ IP,HTTP_X_FORWARDED_FOR:$ IP)); 我已经注释掉用户代理线。然而,没有运气。

I've tried forcing a different IP using: curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip")); and I've commented out the user agent line. However, no luck.

当我从我的本地主机上运行它,它工作正常,没有错误。我在南非和上生成此错误的服务器,是在德国。

When I run it from my localhost, it works fine with no errors. I am in South Africa and the server this error is generated on, is in Germany.

我试过谷歌搜索谷歌的国家政策,但短期出现了。

I've tried googling for Google's country policies but came up short.

任何人都可以解释为什么发生这种情况,我怎么能绕过它?

Can anyone explain why this is happening and how I can bypass it?

推荐答案

此错误表明谷歌认为您的IP地址属于一个的国家限制访问。德国是不是不过的国家之一,因此这很可能是一个错误。请填写下面的表格有这样的更正: https://support.google.com/websearch/接触/ IP

This error indicates that Google believes your IP address belongs to a country with restricted access. Germany is not one of those countries however, so this is likely an error. Please fill out the following form to have this corrected: https://support.google.com/websearch/contact/ip

这篇关于谷歌联系人API与&QUOT响应; countryBlock"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆