0

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

ご協力ありがとうございました

4

1 に答える 1

0

「HTTP エラー: (0) ホストに接続できませんでした」というエラーは、通常、サーバーと Google の間に問題があることを意味します。プロキシ経由で接続していますか?

また、コマンド ラインから「curl https://www.googleapis.com/discovery/v1/apis 」を実行してみてください。

于 2012-05-04T03:27:08.623 に答える