Package test

Source Code of test.WeiboAccountTest

package test;

import org.junit.Before;
import org.junit.Test;
import weibo4j.Timeline;
import weibo4j.examples.oauth2.Log;
import weibo4j.model.Paging;
import weibo4j.model.StatusWapper;
import weibo4j.org.json.JSONArray;
import weibo4j.org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class WeiboAccountTest {

  String accessToken = "2.009q4JaB0boMkW8e5efb98210m4BKY";
  String uid = "1450317544";

  @Before
  public void setUp() {

  }

  //    @Test
  public void testGetUserInfo() {
  }

  @Test
  public void testGetUserPeopleIdList() {
  }

  public static void main(String[] args) {
//    String access_token = args[0];
    String access_token = "2.009q4JaB0boMkW8e5efb98210m4BKY";
    Timeline tm = new Timeline();
//    tm.client.setToken(access_token);
    tm.setToken(access_token);
    try {
//      JSONObject ids = tm.getUserTimelineIdsByUid(args[1]);
      JSONObject ids = tm.getUserTimelineIdsByUid("1450317544");
      Log.logInfo(ids.toString());
      JSONArray array = (JSONArray) ids.get("statuses");

      ArrayList<String> list = new ArrayList<String>();
      for (int i = 0; i < array.length(); ++i) {
        list.add(array.get(i).toString());
      }

      System.out.println(list.size());

      StatusWapper wrapper = tm.getUserTimelineByUid("1450317544", new Paging(1), 0, 0);
      System.out.println(wrapper.getStatuses().size());

      wrapper = tm.getUserTimelineByUid("1450317544", new Paging(2), 0, 0);
      System.out.println(wrapper.getStatuses().size());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of test.WeiboAccountTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.