php – Google Contacts API以“countryBlock”错误响应
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – Google Contacts API以“countryBlock”错误响应,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2266字,纯文字阅读大概需要4分钟。
内容图文
![php – Google Contacts API以“countryBlock”错误响应](/upload/InfoBanner/zyjiaocheng/703/e0a764624927411b9d6e25e59287a39d.jpg)
我有一个从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的国家/地区政策,但却做空了.
任何人都可以解释为什么会发生这种情况以及如何绕过它?
解决方法:
此错误表示Google认为您的IP地址属于country with restricted access.德国不是其中之一,因此这可能是错误的.请填写以下表格以更正:https://support.google.com/websearch/contact/ip
内容总结
以上是互联网集市为您收集整理的php – Google Contacts API以“countryBlock”错误响应全部内容,希望文章能够帮你解决php – Google Contacts API以“countryBlock”错误响应所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。