我正在使用google-api-php-client库测试OAuth2服务,以使用他们的Google帐户访问已登录用户的UserInfo。代码取自examples / userinfo / index.php,几乎没有变化来应对我的主机。运行示例时,它会通过Google登录表单传递。当它回到我的网站时,抛出一个异常如下。
Fatal error: Uncaught exception 'apiIOException' with message 'HTTP Error: (0) couldn't connect to host' in /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiCurlIO.php:120
Stack trace:
#0 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiCurlIO.php(46): apiCurlIO->makeRequest(Object(apiHttpRequest))
#1 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiREST.php(55): apiCurlIO->authenticatedRequest(Object(apiHttpRequest))
#2 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/service/apiServiceResource.php(151): apiREST::execute(Object(apiServiceRequest))
#3 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/contrib/apiPlusService.php(207): apiServiceResource->__call('get', Array)
#4 /home/ztbmwjhd/public_html/apis/at/googleplus/google-plus-access.php(40): PeopleServiceResource->get('me')
#5 /home/ztbmwjhd/public_html/apis/at/googleplus/index.php(2): include_once('/home/ztbmwjhd/...')
#6 {main}
throw in /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiCurlIO.php on line 120
感谢您的帮助
答案 0 :(得分:0)
错误“HTTP错误:(0)无法连接到主机”通常意味着服务器和谷歌之间存在问题。你是通过代理连接的吗?
另外,尝试从命令行运行“curl https://www.googleapis.com/discovery/v1/apis”。