安装适用于Google Analtics PHP的Google客户端库 [英] installing Google Client Library for Google Analtics PHP

查看:159
本文介绍了安装适用于Google Analtics PHP的Google客户端库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我是这个主题的新手,所以我希望我的问题不会太愚蠢.

first of all I am new to this topic, so I hope my question is not too stupid.

我希望我的网站可以通过PHP访问Google Analytics(分析)指标.我遵循了来自Google的说明的每一步. .不幸的是,当我将所有内容上传到服务器上并尝试运行测试站点时,总是会收到以下错误消息:

I want my website to have PHP access to Google Analytics metrics. I followed every step of this description from google. Unfortunately when I upload everything on my server and try to run the test-site, I always get the following error-message:

致命错误:消息此库"未捕获的异常"Exception" 必须通过作曲家或下载完整的软件包进行安装.看 的说明 https://github.com/google/google-api-php-client#installation ."在 /home/users/myftp/dev.mywebsite.com/dashboard/google-api-php-client-master/src/Google/autoload.php:14 堆栈跟踪:#0 /home/users/myftp/dev.mywebsite.com/dashboard/HelloAnalytics.php(8): require_once()#1 /home/users/myftp/dev.mywebsite.com/dashboard/HelloAnalytics.php(104): getService()#2 {main}被抛出 /home/users/myftp/dev.mywebsite.com/dashboard/google-api-php-client-master/src/Google/autoload.php 在第14行

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 /home/users/myftp/dev.mywebsite.com/dashboard/google-api-php-client-master/src/Google/autoload.php:14 Stack trace: #0 /home/users/myftp/dev.mywebsite.com/dashboard/HelloAnalytics.php(8): require_once() #1 /home/users/myftp/dev.mywebsite.com/dashboard/HelloAnalytics.php(104): getService() #2 {main} thrown in /home/users/myftp/dev.mywebsite.com/dashboard/google-api-php-client-master/src/Google/autoload.php on line 14

因此,显然Google客户端库的嵌入存在问题.在错误消息中,它说我必须使用Composer,但是在GitHub文档中,他们说,手动下载也可以.我认为最终这应该没有任何区别吗?我不熟悉composer或GitHub,这就是为什么我手动下载它的原因.

So apparently there is something wrong with the embedding of the Google client library. In the error message it says I have to use Composer, but in the GitHub documentation they say, manual download would be fine as well. I think in the end this shouldn't make any difference? I am not familiar with composer or GitHub, this is why i downloaded it manually.

我将其上载到服务器上,并将其放入与HelloAnalytics.php相同的目录中.我通过

I uploaded it on the server and put it into the same directory like the HelloAnalytics.php. I address it in HelloAnalytics.php via

require_once 'google-api-php-client-master/src/Google/autoload.php'

推荐答案

从外观上看,您使用的是错误的自动加载器.

From the looks of it you are using the wrong autoloader.

src/Google/autoload.php查找作曲家自动加载器,如果不存在该加载器,则会抛出您正在获取的异常.由于您不是使用Composer安装的,因此找不到它,并且会抛出该异常.

src/Google/autoload.php looks for the composer autoloader and if it doesn't exist it throws the exception you are getting. Since you didn't install using Composer it is not found and that exception is thrown.

如果使用git克隆存储库,则将具有正确的SPL自动加载器.如果下载该软件包,它将使用composer自动加载器.

If you clone the repository using git you will have the correct SPL autoloader. If you download the package it uses the composer autoloader.

尝试使用以下方式下载:

Try downloading using:

git clone -b v1-master https://github.com/google/google-api-php-client.git

或切换到v1-master分支并使用自动加载器.您会发现master分支和v1-master分支之间的文件有所不同.

Or switch to the v1-master branch and use this autoloader instead. You will see that file differs between the master branch and the v1-master branch.

这篇关于安装适用于Google Analtics PHP的Google客户端库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆