-1

analytics에서 통계를 소스로 덤프하는 동안이 오류를 발견했습니다.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 

감사합니다.

+0

_ "일일 한도 초과 _"부분이 명확하지 않습니까? –

+0

편집이 도움이되지 않습니다. 이 오류는 수행 할 수있는 일일 조회 수를 초과했음을 알려줍니다. –

+0

그러면 해결책이 될 수 있습니다. – Sanju

답변

0

Google 애널리틱스 API를 사용할 때 알아야 할 몇 가지 할당량이 있습니다.

첫 번째 응용 프로그램은 하루 최대 50000 건의 요청을 처리 할 수 ​​있습니다. 두 번째는 액세스하려는 각보기가 하루에 최대 10000 개의 요청을 만들 수 있다는 것입니다.

일일 한도를 초과했습니다. 할당량은 자정에 재설정됩니다. 태평양 표준시 (태평양 표준시)

해당 할당량 중 하나를 초과했다는 의미입니다. 어느 것이 가장 적합한 지 파악하는 가장 쉬운 방법은 다른보기를 사용하여 요청을 시도하는 것입니다. 작동하면 첫 번째보기에서 할당량을 날려 버렸다는 것을 알게됩니다. 그렇지 않으면 프로젝트의 할당량을 날려 버린 것입니다. 쿼터가 어느 정도 줄어들면 서부 시간대 미국 서부 시간대에 쿼터가 재설정 될 때까지 API에서 다시 액세스 할 수 없습니다.

프로젝트 당 50000 개의 요청의 확장을 요청할 수 있습니다. 분석 API를 활성화하고 할당량 섹션 아래에있는 Google 개발자 콘솔을 통해 매일 최대 할당량의 80 %를 사용할 때 적용 할 수 있도록 확장을 얻으려면 약 한 달이 걸립니다.

하루에 10000 건의 요청의 연장을 요청할 수 없습니다.

+0

감사합니다 DalmTo. – Sanju