* @throws ServiceException if an error occurs with the Google Analytics API.
*/
public DataFeedExample() throws AuthenticationException, IOException, ServiceException {
// Configure GA API.
AnalyticsService as = new AnalyticsService("gaExportAPI_acctSample_v2.0");
// Client Login Authorization.
as.setUserCredentials(CLIENT_USERNAME, CLIENT_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);
query.setStartDate("2008-10-01");
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);
}