我在將分析數據作爲來源轉儲時發現此錯誤。com.google.api.client.googleapis.json.GoogleJsonResponseException:403禁止例外
任何人都可以說這可能是什麼.. ??
public Get getAnalyticsReportDefination() {
String month = ((fromCal.get(Calendar.MONTH) + 1) < 10 ? "0" + (fromCal.get(Calendar.MONTH) + 1) : "" + (fromCal.get(Calendar.MONTH) + 1));
String date = (fromCal.get(Calendar.DATE) < 10 ? "0" + fromCal.get(Calendar.DATE) : "" + fromCal.get(Calendar.DATE));
String toMonth = ((toCal.get(Calendar.MONTH) + 1) < 10 ? "0" + (toCal.get(Calendar.MONTH) + 1) : "" + (toCal.get(Calendar.MONTH) + 1));
String toDate = (toCal.get(Calendar.DATE) < 10 ? "0" + toCal.get(Calendar.DATE) : "" + toCal.get(Calendar.DATE));
String TimeStamp1 = fromCal.get(Calendar.YEAR) + "-" + month + "-" + date;
String TimeStamp2 = toCal.get(Calendar.YEAR) + "-" + toMonth + "-" + toDate;
log.info("Google Analytics Stats for date range " +TimeStamp1 + " to " +TimeStamp2);
String accessToken = gleTokenInf.getAccessToken();
String refreshToken = gleTokenInf.getRefreshToken();
Analytics analytics = null;
NetHttpTransport netHttpTransport = new NetHttpTransport();
if (accessToken != null && refreshToken != null) {
JacksonFactory jacksonFactory = new JacksonFactory();
GoogleCredential credential =new GoogleCredential.Builder().setTransport(netHttpTransport)
.setJsonFactory(jacksonFactory).setClientSecrets(CLIENT_ID, CLIENT_SECRET).build();
credential.setAccessToken(accessToken);
credential.setRefreshToken(refreshToken);
analytics=new Analytics.Builder(netHttpTransport, jacksonFactory, credential).setApplicationName(APPLICATION_NAME).build();
try {
//AT a time we can get only 7 dimensions and 10 metrics
apiQuery = analytics.data().ga().get("ga:" + gleTokenInf.getProfileId(), TimeStamp1, TimeStamp2,getMetrics());
apiQuery.setDimensions(getDimensions());
StringBuilder source = new StringBuilder();
int len = FilterConditions.length;
for (int i = 0; i < len; i++) {
source.append(FilterConditions[i]).append(filterExpression).append(FilterValues[i]).append(FilterType);
}
apiQuery.setFilters(source.substring(0, source.length() - 1));
gaData = apiQuery.execute();
} catch (Exception ex) {
ex.printStackTrace();
}
}
return apiQuery;
}
的錯誤是:提前
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Daily Limit Exceeded. The quota will be reset at midnight Pacific Time (PT). You may monitor your quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/analytics/quotas?project=433676821622",
"reason" : "dailyLimitExceeded",
"extendedHelp" : "https://console.developers.google.com/apis/api/analytics/quotas?project=433676821622"
} ],
"message" : "Daily Limit Exceeded. The quota will be reset at midnight Pacific Time (PT). You may monitor your quota usage and adjust limits in the API Console
}
----------
metrics: ga:transactions,ga:transactionRevenue,ga:itemRevenue,ga:transactionShipping,ga:transactionTax
dimensions: ga:campaign,ga:adGroup
感謝。
_「每日限制超出」_的哪一部分不清楚? –
編輯不起作用。錯誤是告訴你,你已經超出了你允許執行的每日查詢次數。 –
那麼可能是什麼解決方案。 – Sanju