简体   繁体   中英

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.

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. 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.

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).

You have to use a refresh token. Look here Offline Access .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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