简体   繁体   中英

Make a query to GA api with a service account credential

I discovers the use of GA report API. Yours helps and precisions are very important for me. I want to get datas from GA report api with a json format.

I have making a test : I have installed the GA client with composer, create an app, a service account credential, and create the HelloAnalytics.php script. It's ok I get datas with this script.

But, I want to retrieve datas with a json format. Then, I think that this method is not good. I think that I must use a query to get datas from GA api. Isn't it?

If yes, how can I associate the service account credential with a query to GA api? By default, a query to GA api has need 1 token.

Can you explain me how to proceed? Thanks very much for your help.

You mentioned composer which leades me to beleave that you are using php. If you are using the PHP client library then it returns all the data to you as objects.

Google APIs by default return their data as Json but the client libraries to make it easier for you return it as an object.

You might try the json_encode($b) method which should if memory serves take an object and turn it into json for you.

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