[GoogleAnalytics API] エラー:This library must be installed via composer or by downloading the full package. が出るときの対処法

GoogleAnalytics APIを利用したプログラムを実行すると、”This library must be installed via composer or by downloading the full package.”というエラーが出る場合があります。

PHP Fatal error:  Uncaught exception 'Exception' with message 
'This library must be installed via composer or by downloading the full package. 
See the instructions at https://github.com/google/google-api-php-client#installation.' 
in google-api-php-client\src\Google\autoload.php:14
 
Stack trace:
#0 sample.php(10): require_once()
#1 sample.php(106): getService()
#2 {main}
  thrown in google-api-php-client\src\Google\autoload.php on line 14


これは、ダウンロードしたSDKに必要なファイルがない場合に発生します。


Google Analyticsのサイトでは、https://github.com/google/google-api-php-client#installationからSDKをダウンロードするよう記載がありますが、このページのドキュメントを見ると、下記の注意が記載されています。

NOTE: If you arrived here from  developers.google.com , 
you should be using the v1-branch of this repo




というわけで、githubからzipパッケージをダウンロードする場合は、v1-masterのブランチである下記のURLからダウンロードを行う必要があります。
https://github.com/google/google-api-php-client/tree/v1-master


ページにアクセスしたら、リスト上部の右側にあるDownload ZIPをクリックすると、SDKを入手できます。

関連記事

コメントを残す

メールアドレスが公開されることはありません。