我正在尝试从https://developers.google.com/analytics/solutions/articles/hello-analytics-api运行一个简单的示例来访问 Google 分析数据。
google-api-java-client-1.17.0-rc.zip
从https://code.google.com/p/google-api-java-client/downloads/list下载了 java api-library ,
有示例代码显示编译错误:
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
private static Analytics initializeAnalytics() throws Exception {
Credential credential = OAuth2Native.authorize(
HTTP_TRANSPORT, JSON_FACTORY, new LocalServerReceiver(),
Arrays.asList(AnalyticsScopes.ANALYTICS_READONLY));
Analytics analytics = Analytics.builder(HTTP_TRANSPORT, JSON_FACTORY)
.setApplicationName("Hello-Analytics-API-Sample")
.setHttpRequestInitializer(credential)
.build();
我在类路径中添加了所有库,但库似乎没有一些类:
OAuth2Native
AnalyticsScopes
Analytics
但是这些课程出现在http://code.google.com/p/google-api-java-client/source/browse/shared/shared-sample-cmdline/src/main/java/com/google/api/services/samples/shared/cmdline/oauth2/OAuth2Native.java?repo=samples&r=89662bd8ab341647b3f0aab8ed6a4fb444f478c2