Php 谷歌联系API的回应是;countryBlock“;错误
我有一个从谷歌联系人导入联系人的应用程序。该应用程序运行良好,直到今天早上我们更改了API的“所有者”。它是在我的个人账户下建立的,用于发展目的 在设置了所有内容后,谷歌开始用以下内容进行响应:Php 谷歌联系API的回应是;countryBlock“;错误,php,api,google-contacts-api,country,Php,Api,Google Contacts Api,Country,我有一个从谷歌联系人导入联系人的应用程序。该应用程序运行良好,直到今天早上我们更改了API的“所有者”。它是在我的个人账户下建立的,用于发展目的 在设置了所有内容后,谷歌开始用以下内容进行响应: Array ( [error] => Array ( [errors] => Array ( [0] => Array
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
)
)
这是生成错误的行和函数声明(它们位于不同的文件中):
我尝试使用以下命令强制使用不同的IP:curl_setopt($ch,CURLOPT_HTTPHEADER,array(“REMOTE_ADDR:$IP”,“HTTP_X_FORWARDED_FOR:$IP”)代码>我已经注释掉了用户代理行。然而,没有运气
当我从本地主机运行它时,它工作正常,没有错误。我在南非,产生此错误的服务器在德国
我曾在谷歌上搜索过谷歌的国家政策,但没有成功
有人能解释为什么会发生这种情况,以及我如何绕过它吗?这个错误表明谷歌相信你的IP地址属于一个网络。然而,德国不是这些国家之一,因此这可能是一个错误。请填写以下表格以更正此问题:检查此线程,它与此类似。它说,这个问题是通过http:requests(而不是https:)联系谷歌API中央核心造成的
Hi@Eric,昨天给你发了一条关于G+的消息。:)嗯,我没看到有什么进展。我更改了我的隐私设置,你能再试一次吗?嗨,埃里克,又发了一次。嗨,埃里克,我刚刚在google+上给你发了一个PM,还有一个关于这个问题的问题。我的Joomla安装中还有一个不起作用的登录API组件。谢谢DarkRanger,我已经要求团队对此进行调查。
$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;
}