Exemplo n.º 1
0
  /**
   * 認証したユーザのフレンドタイムラインを取得します。<br>
   * <i>http://h.hatena.ne.jp/api/statuses/friends_timeline.xml</i>
   *
   * @see <a
   *     href="http://h.hatena.ne.jp/api#statuses-friends_timeline">statuses/friends_timeline</a>
   * @param op 集合操作
   * @param page 取得するページです。最大数は100です。
   * @param count 取得数を指定します。最大数は 200 です。
   * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。
   * @return 認証したユーザのフレンドタイムライン
   * @throws HatenaHaikuException
   * @since v1.1.0
   */
  public <T> T getFriendsTimeline(ReduceOp<Status, T> op, int page, int count, Date since)
      throws HatenaHaikuException {
    try {
      QueryParameter param = new QueryParameter();
      param.setPage(page);
      param.setCount(count);
      param.setSince(since);
      String resultXml =
          HttpUtil.doGet(loginUser, URL_FRIENDS_TIMELINE_XML, param, isNeedHttpLog());
      return toStatusList(op, XmlUtil.getRootElement(resultXml));

    } catch (ParserConfigurationException e) {
      throw new HatenaHaikuException("ParserConfigurationException発生。", e);

    } catch (SAXException e) {
      throw new HatenaHaikuException("SAXException発生。", e);

    } catch (IOException e) {
      throw new HatenaHaikuException("IOException発生。", e);
    }
  }
Exemplo n.º 2
0
  /**
   * 認証したユーザのユーザタイムラインを取得します。<br>
   * <i>http://h.hatena.ne.jp/api/statuses/user_timeline.xml</i>
   *
   * @see <a href="http://h.hatena.ne.jp/api#statuses-user_timeline">statuses/user_timeline</a>
   * @param op 集合操作
   * @param page 取得するページです。最大数は100です。
   * @param count 取得数を指定します。最大数は 200 です。
   * @param since その日時よりも新しい投稿のみに絞り込むための日時を指定します。
   * @param isHot 人気順取得用かどうか
   * @return 認証したユーザのユーザタイムライン
   * @throws HatenaHaikuException
   * @since v1.0.0
   */
  private <T> T _getUserTimeline(
      ReduceOp<Status, T> op, int page, int count, Date since, boolean isHot)
      throws HatenaHaikuException {
    try {
      QueryParameter param = new QueryParameter();
      if (isHot) {
        param.setSort(QueryParameter.HOT); // 人気順
      }
      param.setPage(page);
      param.setCount(count);
      param.setSince(since);
      String resultXml = HttpUtil.doGet(loginUser, URL_USER_TIMELINE_XML, param, isNeedHttpLog());
      return toStatusList(op, XmlUtil.getRootElement(resultXml));

    } catch (ParserConfigurationException e) {
      throw new HatenaHaikuException("ParserConfigurationException発生。", e);

    } catch (SAXException e) {
      throw new HatenaHaikuException("SAXException発生。", e);

    } catch (IOException e) {
      throw new HatenaHaikuException("IOException発生。", e);
    }
  }