Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: program won't compile, can't get data from google analytics

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default program won't compile, can't get data from google analytics

    Trying to take data from google analytics and print
    Hi,

    I am trying to program a basic code to take information from google analytics and print it out. I wrote some code, whats wrong. (user/pass) removed for privacy reasons.

    I am trying to make it all occur in one class for now (Its the beta version to make sure I can download information and use it before I start the real program). I just want to take information and print it out. I know the table id isn't set, but the program won't compile:

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at xyz.xyzStart.main(xyzStart.java:96)


    --

    also can someone explain how to connect to google analytics and get information. I read googles help, and api but I'm still stuck
    ------
    [highlight = java]
    package xyz;

    import com.google.gdata.client.analytics.AnalyticsService ;
    import com.google.gdata.client.analytics.DataQuery;
    import com.google.gdata.data.analytics.Aggregates;
    import com.google.gdata.data.analytics.DataEntry;
    import com.google.gdata.data.analytics.DataFeed;
    import com.google.gdata.data.analytics.DataSource;
    import com.google.gdata.data.analytics.Dimension;
    import com.google.gdata.data.analytics.Metric;
    import com.google.gdata.data.analytics.Segment;
    import com.google.gdata.util.AuthenticationException;
    import com.google.gdata.util.ServiceException;

    import java.io.IOException;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.List;




    public class xyzStart {

    private static final String id= "-";
    private static final String Pass = "-";
    public DataFeed feed;


    /**
    * trial run of program
    */
    public xyzStart(){
    // try{
    String started = "the program has started";
    System.out.println(started);
    dataFeedSet();
    printFeedData();
    // }

    //catch{

    // }catch{

    // }catch{
    }

    /**
    * Need to edit later, basics to be used/tinkered with
    *
    */
    public void dataFeedSet(){
    AnalyticsService as = new AnalyticsService("xyz.com");

    //authorization
    as.setUserCredentials(id, Pass);
    // GA Data Feed query uri.
    String baseUrl = "https://www.google.com/analytics/feeds/data";
    DataQuery query = new DataQuery(new URL(baseUrl));
    query.setIds(TABLE_ID);
    query.setDimensions("ga:source,ga:medium");
    query.setMetrics("ga:visits,ga:bounces");
    query.setSegment("gaid::-11");
    query.setFilters("ga:medium==referral");
    query.setSort("-ga:visits");
    query.setMaxResults(5);

    // allow user to preset? or alter?
    query.setStartDate("2011-06-01");

    //latest date solution? have user enter?
    query.setEndDate("2008-10-31");
    URL url = query.getUrl();
    System.out.println("URL: " + url.toString());

    // Send our request to the Analytics API and wait for the results to
    // come back.
    feed = as.getFeed(url, DataFeed.class);



    }

    public void printFeedData(){

    System.out.println("\n-------- Important Feed Information --------");
    System.out.println(
    "\nFeed Title = " + feed.getTitle().getPlainText() +
    "\nFeed ID = " + feed.getId() +
    "\nTotal Results = " + feed.getTotalResults() +
    "\nSart Index = " + feed.getStartIndex() +
    "\nItems Per Page = " + feed.getItemsPerPage() +
    "\nStart Date = " + feed.getStartDate().getValue() +
    "\nEnd Date = " + feed.getEndDate().getValue() +
    "\nContains Sampled Data = " + feed.getContainsSampledData().getValue().toString( ));
    }

    public static void main(String[] args) {

    }

    }
    [/ highlight]
    Last edited by nervous; June 20th, 2012 at 06:57 PM.


  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: program won't compile, can't get data from google analytics

    Use this to express your code. "[highlight = java] PASTE CODE HERE [/ highlight]"

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: program won't compile, can't get data from google analytics

    ok, will do

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: program won't compile, can't get data from google analytics

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/60857-thread-started-nervous-trying-take-data-google-analytics.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


Similar Threads

  1. Trying to make a Car program and I can't seem to get it to compile
    By Necroshade in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 25th, 2011, 06:45 PM
  2. [SOLVED] Compile a set of java files for a sudoku program
    By kanishk.dudeja in forum Java Theory & Questions
    Replies: 7
    Last Post: June 16th, 2011, 09:54 AM
  3. Data Gathering Java Program
    By BLACKWOLFXIII in forum Java Networking
    Replies: 2
    Last Post: May 17th, 2011, 10:33 AM
  4. anagram program wont compile please help
    By Rusak in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 26th, 2011, 06:23 PM
  5. Anagram program wont compile
    By Rusak in forum Member Introductions
    Replies: 0
    Last Post: March 25th, 2011, 02:38 PM