public static void main(String[] args) { String access_token = args[0]; String id = args[1]; Timeline tm = new Timeline(access_token); try { Status status = tm.destroy(id); Log.logInfo(status.toString()); } catch (WeiboException e) { e.printStackTrace(); } }
public static void main(String[] args) { String access_token = args[0]; String statuses = args[1]; Timeline tm = new Timeline(); tm.client.setToken(access_token); try { Status status = tm.UpdateStatus(statuses); Log.logInfo(status.toString()); } catch (WeiboException e) { e.printStackTrace(); } }
public static void main(String[] args) { String access_token = args[0]; String mid = args[1]; Weibo weibo = new Weibo(); weibo.setToken(access_token); Timeline tm = new Timeline(); try { JSONObject id = tm.QueryId(mid, 1, 1); Log.logInfo(String.valueOf(id)); } catch (WeiboException e) { e.printStackTrace(); } }
/** @param args */ public static void main(String[] args) { String access_token = args[0]; Weibo weibo = new Weibo(); weibo.setToken(access_token); Timeline tm = new Timeline(); try { List<Status> status = tm.getRepostByMe(); for (Status s : status) { Log.logInfo(s.toString()); } } catch (WeiboException e) { e.printStackTrace(); } }
public static void main(String[] args) { String access_token = args[0]; Timeline tm = new Timeline(); tm.client.setToken(access_token); try { StatusWapper status = tm.getHomeTimeline(); for (Status s : status.getStatuses()) { Log.logInfo(s.toString()); } System.out.println(status.getNextCursor()); System.out.println(status.getPreviousCursor()); System.out.println(status.getTotalNumber()); System.out.println(status.getHasvisible()); } catch (WeiboException e) { e.printStackTrace(); } }
public List<StatusData> GetRepostStatus(String statusId, int mount) { List<Status> status; try { status = tm.getRepostTimeline(statusId, mount, 1).getStatuses(); List<StatusData> statusDatas = new ArrayList<StatusData>() {}; for (Status status2 : status) { statusDatas.add(DataConverter.ConvertFrom(status2)); } return statusDatas; } catch (WeiboException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new ArrayList<StatusData>(); }
public List<StatusData> GetUserStatus(String people, int mount) { // TODO Auto-generated method stub try { List<Status> statuss = tm.getUserTimelineByName(people, mount, 1, 1).getStatuses(); List<StatusData> statusDatas = new ArrayList<StatusData>(); for (Status status : statuss) { statusDatas.add(DataConverter.ConvertFrom(status)); } return statusDatas; } catch (WeiboException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new ArrayList<StatusData>(); }
/** 本线程每 ??秒?分钟 执行一次 为每个uid 抓取(10-99)条最新微博 不重复的插入数据库和缓存 */ @Override public void run() throws NullPointerException { while (true) { // TODO 通过uid 获取该uid的微博 并且插入数据库,插不重复的数据 page 从1开始 // since_id false int64 // 若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。 // max_id false int64 若指定此参数,则返回ID小于或等于max_id的微博,默认为0。 // 是id 经测试 长的mid和短的id都可以作为参数 // 这里用id(短的)非mid 作为statusBean的微博id Timeline timeline = new Timeline(); timeline.client.setToken(access_token); StatusWapper statusWapper = null; String autherUid = "1197161814"; // wid: 3514156970081400 try { // 最多200条 //uid 1193491727 取200+条 200-300 statusWapper = timeline.getRepostTimeline("3514176795867274", new Paging(2, 199)); } catch (WeiboException e) { e.printStackTrace(); } // 经测试发现 // 通过wid查询转发,返回的StatusWapper包的Status里获取的每个status的getUser就是这个转发的人的信息 List<Status> status = statusWapper.getStatuses(); System.out.println("status.size: " + status.size()); for (int i = 0; i < 150; i++) { // 先取5个status System.out.println("第 i: " + i + " 个status的被转发次数:" + status.get(i).getRepostsCount()); // 只要在这个 status集合里的肯定在数组的0位,肯定放入了 try { userDeep[i][9][9] = status.get(i).getUser().getScreenName(); } catch (NullPointerException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (status.get(i).getRepostsCount() == 0) { try { System.out.println("首次被转发次数是 0,转发的人是: " + status.get(i).getUser().toString()); } catch (NullPointerException e) { e.printStackTrace(); } continue; } else { // 超过1个人转发 // for (int j = 0; j < count; j++) {// 尼玛 逻辑乱出翔 StatusWapper statusWapper1 = null; System.out.println("weibo ID:--> " + status.get(i).getId()); // 显示下 // 当前被转发的转发微博的 // id try { statusWapper1 = timeline.getRepostTimeline(status.get(i).getId(), new Paging(1, 100)); } catch (WeiboException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<Status> status1 = statusWapper1.getStatuses(); int count1 = status1.size(); if (count1 > 5) { count1 = 5; System.out.println("深度为 二 第 超过超过超过5 "); } for (int k = 0; k < count1; k++) { // 深度为2 System.out.println( "深度为 二 第k: " + k + "个status1的被转发次数:" + status1.get(k).getRepostsCount()); // userDeep[i][1] = status1.get(k).getUser().getScreenName(); if (status1.get(k).getRepostsCount() == 0) { System.out.println( "首次被转发次数是 1,转发的人是: " + status.get(i).getUser().toString() + "二次被转发的次数为0,转发的人是: " + status1.get(k).getUser().toString()); continue; } else if ( /* status1.get(k).getRepostsCount() == 1 && */ isGz( autherUid, status1.get(k).getUser().getId())) { System.out.println( "首次被转发次数是 1(但是关注作者),深度是 1,转发的人是: " + status.get(i).getUser().toString() + "二次被转发次数是1,深度是2,转发的人是:" + status1.get(k).getUser().toString()); continue; } else { // 被转发 而且没有关注作者 userDeep[i][k][9] = status1.get(k).getUser().getScreenName(); // 遍历转发此 转发微博的 人数 // for(int l = 0;l<count2;l++){ StatusWapper statusWapper2 = null; // 深度为3 try { statusWapper2 = timeline.getRepostTimeline(status1.get(k).getId(), new Paging(1, 100)); } catch (WeiboException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<Status> status2 = statusWapper2.getStatuses(); int count3 = status2.size(); if (count3 > 5) { count3 = 5; System.out.println("深度为 三 size 超过超过超过5 "); } for (int m = 0; m < count3; m++) { // userDeep[i][2] = status2.get(m).getUser().getScreenName(); System.out.println( "深度为 三 第m:" + m + "个status2的杯转发次数是:" + status2.get(m).getRepostsCount()); if (status2.get(m).getRepostsCount() == 0) { System.out.println( "首次被转发次数是 1,转发的人是: " + status.get(i).getUser().toString() + "二次被转发的次数为0,转发的人是: " + status1.get(k).getUser().toString() + "三次杯转发次数为0,转发的人是: " + status2.get(m).getUser().toString()); } else if (isGz(autherUid, status2.get(m).getUser().getId())) { System.out.println( "首次被转发次数是 1 (但是关注作者),深度是 1,转发的人是: " + status.get(i).getUser().toString() + "二次被转发次数是1,深度是2,转发的人是:" + status1.get(k).getUser().toString() + "三次转发次数是1,转发的人是: " + status2.get(m).getUser().toString()); } else { userDeep[i][k][m] = status2.get(m).getUser().getScreenName(); System.out.println( "深度为 --3-- 的转发者 --> 首先0次转发人是 :" + status.get(i).getUser().toString() + " -->2次转发人是: " + status1.get(k).getUser().toString() + " --->3次转发人是 : " + status2.get(m).getUser().toString()); } } } } } // System.out.println("当前转的id: " + status.get(i).getId()); // System.out.println("原id :"+ // status.get(i).getRetweetedStatus().getId()); // System.out.println("转发者 :"+status.get(i).getUser().toString());// // 转发者属性 // System.out.println("source: "+status.get(i).getSource()); // // 来源 // System.out.println("转发的status: "+status.get(i).getRetweetedStatus().toString());// // 转发的status } // for (int i = 0; i < userDeep.length; i++) { // if (userDeep[i][0] != null) { // System.out.print(i + ": "); // for (int j = 0; j < userDeep[i].length; j++) { // if (userDeep[i][j] != null) { // System.out.print(userDeep[i][j] + " <-- "); // } // } // System.out.println(); // } // } // 让数组的9 放 父节点信息 for (int i = 0; i < userDeep.length; i++) { if (userDeep[i][9][9] != null) { System.out.print(i + ": lv-1-" + userDeep[i][9][9]); for (int j = 0; j < userDeep[i].length - 2; j++) { if (userDeep[i][j][9] != null) { System.out.print(" <-- lv-2- " + userDeep[i][j][9]); for (int k = 0; k < userDeep[i][j].length - 2; k++) { if (userDeep[i][j][k] != null) { System.out.println(" <-- lv-3- " + userDeep[i][j][k]); } } System.out.println(); } } System.out.println(); } } // 1s = 1000ms 1min = 60*1000 = 60000 sleep(6000 * 1000); } }