2

我正在使用以下代码获取 Google Plus 帖子,

public class Test { 

 /** E-mail address of the service account. */ 
 private static final String SERVICE_ACCOUNT_EMAIL = "4353545    gggggggggg.apps.googleusercontent.com"; 
/** Global instance of the HTTP transport. */ 
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport(); 
/** Global instance of the JSON factory. */ 
private static final JsonFactory JSON_FACTORY = new JacksonFactory(); 
private static Plus plus; 
public static void main(String[] args) { 
  try { 
    try { 
    GoogleCredential credential = new GoogleCredential.Builder() 
          .setClientSecrets("4353545gggggggggg.apps.googleusercontent.com", 
      "gdfgfgdfgdfgdfgdfggf") 
     .build(); 
  plus = new Plus.Builder(HTTP_TRANSPORT,JSON_FACTORY,credential).build(); 
     getActivity(); 
            // success! 
            return; 

    /** Get an activity for which we already know the ID. */ 
    private static void getActivity() throws IOException { 
    String activityId = "z12stbfxcpmkuthac04ci3gjvoywglkwx0k"; 
    Activity activity = plus.activities().get(activityId).execute(); 

 System.out.println("id: " + activity.getId()); 
 System.out.println("url: " + activity.getUrl()); 
 System.out.println("content: " + 
 activity.getObject().getContent()); 
 } 
 } 

运行此代码时,我收到以下错误,

403 Forbidden 
{ 
  "code" : 403, 
  "errors" : [ { 
    "domain" : "usageLimits", 
    "message" : "Daily Limit Exceeded. Please sign up", 
    "reason" : "dailyLimitExceededUnreg", 
    "extendedHelp" : "https://code.google.com/apis/console" 
  } ], 
  "message" : "Daily Limit Exceeded. Please sign up" 
} 

我怎样才能解决这个问题?

4

2 回答 2

1

您确实收到了 JSON 响应,但似乎是因为您超出了尝试次数,API 没有返回任何内容。可能是您有一天有限尝试的测试帐户等,

于 2012-06-28T16:13:14.027 回答
1

我不知道您尝试了多少次,但关闭extendedHelp URL,我检查并看到Google 每天允许10,000 名访问者。您是否可能超过 10,000 名访客或浏览量?

礼貌限制:10,000 个请求/天

于 2012-06-28T16:39:57.400 回答