Esempio n. 1
0
  // NOTE: /api/0/stream/contents
  private Reader readStreamContents(
      long syncTime, long startTime, IItemListHandler handler, String continuation)
      throws IOException, ReaderException, RemoteException {
    initAuth();

    StringBuilder buff = new StringBuilder(URL_API_STREAM_CONTENTS.length() + 128);
    buff.append(URL_API_STREAM_CONTENTS);
    String stream = handler.stream();
    if (stream != null) {
      if (stream.equals(STATE_READING_LIST)) stream = STATE_GOOGLE_READING_LIST;
      else if (stream.equals(STATE_STARRED)) stream = STATE_GOOGLE_STARRED;
      buff.append("/").append(Utils.encode(stream));
    }
    buff.append("?client=newsplus&ck=").append(syncTime);
    if (handler.excludeRead()) {
      buff.append("&xt=").append(STATE_GOOGLE_READ);
    }
    if (continuation != null && continuation.length() > 0) {
      buff.append("&c=").append(continuation);
    }
    if (startTime > 0) {
      buff.append("&ot=").append(startTime);
    }
    int limit = handler.limit();
    limit = (limit > SYNC_MAX_ITEMS || limit == 0) ? SYNC_MAX_ITEMS : limit;
    if (limit > 0) {
      // google only allows max 1000 at once
      buff.append("&n=").append(limit > SYNC_MAX_ITEMS ? SYNC_MAX_ITEMS : limit);
    }
    buff.append("&r=").append(handler.newestFirst() ? "n" : "o");

    return doGetReader(buff.toString());
  }
Esempio n. 2
0
  // NOTE: /api/0/stream/items/ids
  private Reader readStreamItemIds(long syncTime, IItemIdListHandler handler)
      throws IOException, ReaderException, RemoteException {
    initAuth();

    StringBuilder buff = new StringBuilder(URL_API_STREAM_ITEM_IDS.length() + 128);
    buff.append(URL_API_STREAM_ITEM_IDS);
    buff.append("?output=json"); // xml or json
    String uid = handler.stream();
    if (uid != null) {
      buff.append("&s=");
      buff.append(Utils.encode(uid));
    }
    if (handler.excludeRead()) {
      buff.append("&xt=").append(STATE_GOOGLE_READ);
    }
    int limit = handler.limit();
    if (limit > 0) {
      buff.append("&n=").append(limit);
    }
    buff.append("&r=").append(handler.newestFirst() ? "n" : "o");

    return doGetReader(buff.toString());
  }