简体   繁体   English

从未经授权的cron作业中的用户获取Google Analytics(分析)数据

[英]Get Google Analytics Data from a user in a cron job without authorizing

I'm familiar in how to get data from a user when he authorizies the application. 我熟悉如何在用户授权应用程序时从用户那里获取数据。 I'm also saving his oauthtoken and oauthsecret. 我还保存了他的oauthtoken和oauthsecret。

The problem I'm encountering now, is, that I want to update the analytics statistics every day. 我现在遇到的问题是,我想每天更新分析统计信息。 And I want to run this in a cronjob. 我想在cronjob中运行它。 So I can't ask the user every time for permission. 因此,我不能每次都向用户征求许可。 What would be the way to retrieve the data from a user that has already authorized my site before? 从以前已经授权我的网站的用户那里检索数据的方式是什么?

I need the statistics every day without his permission so I can display it to the user. 我每天都需要未经他许可的统计信息,因此可以将其显示给用户。 Is there a way for it? 有办法吗?

"Without his permission" is not going to happen (am from context it is not what you mean). “未经他的许可”将不会发生(从上下文来看,这不是你的意思)。 To get permanent permission you need to register your php app through the api console, and have to user add permissions to his account via the service account for your app. 要获得永久许可,您需要通过api控制台注册您的php应用,并且必须通过您应用的服务帐户向用户帐户添加权限。

Found a tutorial that should be good enough to get you going: http://enarion.net/programming/php/google-client-api/google-client-api-php/ (obviously web-centered bit should be adaptable to the command line). 找到了一个足以使您入门的教程: http : //enarion.net/programming/php/google-client-api/google-client-api-php/ (显然,以Web为中心的位应该适合于命令行)。

You have to use a refresh token. 您必须使用刷新令牌。 Look here Offline Access . 在这里查看“ 离线访问”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM