需要一个轻量级的

需要一个轻量级的

本文介绍了GAPI 正在关闭 Google Analytics 需要一个轻量级的 PHP API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是昨天关闭的 GAPI 用户的问题:

This is the question for GAPI users which shut down yesterday:

https://code.google.com/p/gapi-google-analytics-php-interface

GAPI - Google Analytics API PHP Interface 是一个简单但功能强大的 Google Analytics 库.它使用的是旧 API 并需要完整的 Google 用户名和密码,这确实是老式的,但它的工作原理很吸引人.但是我们在这里,我们基于 GAPI 的代码给出了信息:

GAPI - Google Analytics API PHP Interface was a simple yet powerfull Google Analytics library. It was using the old API and required full Google username and password which was really old fashioned but it was working like a charm. bUT here we are, our GAPI based codes gives the message:

无法验证用户 AuthForInstalledApps

唯一的选择是使用oAuth2.0,那么我们得到了什么?

The only option is to use the oAuth2.0, so what we got here?

Google 客户端库: https://github.com/google/google-api-php-client

此库的问题在于,它是一个通用库,而不仅仅是用于 Analytics.因此,如果您只想将它​​用于 Analytics,它有很多不必要的类,例如 Fitness、Adsense、Book、Blogger?好的一面是,我们可以只用一个基本的 php 类来完成整个工作,现在为什么我们需要使用数千行代码?

The issue with this library is, it's a common library, not just for Analytics. So if you're going to use it just for Analytics, it has lots of unnecessary classes like, Fitness, Adsense, Book, Blogger? The good side was, we can use just one basic php class to do the whole work, now why do we need to use thousand lines of codes?

我真的阅读了很多问答,尝试了几乎所有针对该问题的 PHP 类,但它们都引用了 Google 客户端库.当我发现 wanze 的分析 API 时,我真的很兴奋,因为它使用了 Oauth 2.0 和更新了库,但这一行返回空,所以它不起作用.

I really read lots of Q&A, tried nearly all the PHP classes for that issue but they all referenced Google Client Library. When I found wanze's Analytics API I was really excited because it's using Oauth 2.0 and an updated library but this line returned empty, so it didn't work.

$auth = $ga->auth->getAccessToken($code);

所以我们在这里寻找一个轻量级的 PHP 库,仅用于 Google Analytics,使用 oAuth2,除了客户端库之外,您还有什么建议?

So here we are, looking for a lightweight PHP library just for Google Analytics, using oAuth2, what's your suggestions beside Client Library?

推荐答案

我是维护者,今天就 GAPI 和 OAuth2 要求与我联系.刚刚发布了GitHub 上的 2.0 版,来自社区的贡献.

I am maintainer and was contacted today regarding GAPI and the OAuth2 requirement. Just released Version 2.0 on GitHub from contributions from the community.

2.0 版是 1.3/1.4 的直接移植,应该与您现有的系统匹配.请注意,OAuth2 将要求您创建服务帐户",然后下载P12 文件上传到服务器.最后,您需要调整开发人员控制台,启用分析 API".最后,授予这个新用户对您要访问的 Google Analytics(分析)帐户的读取和分析"权限.

Version 2.0 is a straight port from 1.3/1.4 and should match your existing system. Note that OAuth2 will require you to create a 'service account' and then download a P12 file to upload to the server. Finally you will need to adjust the developers console, enable 'analytics API'. Finally give this new user 'Read and Analyse' permissions on the Google Analytics accounts you want to access.

这篇关于GAPI 正在关闭 Google Analytics 需要一个轻量级的 PHP API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 02:50