Using cURL with Google Analytics API?

I have been researching this for hours and I cant seem to find an answer to this. For people that know cURL this is going to seem like a dumb question but answering this will probably help a lot of people. I am trying to use Google Analytics to post custom SEO reports and the best way seems to be using XML. The sample code they give is posted below:

# Copyright 2009 Google Inc. All Rights Reserved
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
# Access the Data Feed of the GA Data Export API through cURL

USER_EMAIL="" #Insert your Google Account email address here
USER_PASS="" #Insert your password here
TABLE_ID="" #Insert your table ID here (ie ga:1234)

googleAuth="$(curl -s \\
  -d Email=$USER_EMAIL \\
  -d Passwd=$USER_PASS \\
  -d accountType=GOOGLE \\
  -d source=curl-dataFeed-v2 \\
  -d service=analytics \\
  | awk /Auth=.*/)"


curl $feedUri --silent \\
  --header "Authorization: GoogleLogin $googleAuth" \\
  --header "GData-Version: 2"

The problem is I have no idea what file extension to use for this code and how do I call this information on a web page? Does anyone know the answer to this?

It’s a bash script. You don’t really need a file extension. If you named the file ganalytics, then this might be successful from php.


I say might because were making assumptions about your system and environment. Btw- this won’t work on a typical windows system.