Example #1
0
  @SuppressWarnings("finally")
  public JSONObject getKeyWords(JSONObject semiData) {
    JSONObject keyWords = new JSONObject();

    try {
      this.buildIndex(semiData);
      this.getIndexInfo(this.indexDir, 4);
      this.generateWekaFile(this.termList, this.maxDocNum, this.wekaFile);
      JSONArray array = this.Cluster(this.wekaFile, 7);
      int totalNum = 0;
      for (int i = 0; i < array.length(); i++) {
        totalNum += array.getJSONArray(i).length();
      }
      keyWords.put("maxFreq", this.maxFreq);
      keyWords.put("totalNum", totalNum);
      keyWords.put("WordList", array);
    } catch (WeiboException e) {
      System.out.print("getKeyWords++++++weibo\n");
      System.out.print("error:" + e.getError() + "toString:" + e.toString());
      keyWords.put("error", e.getError());
      e.printStackTrace();
    } catch (Exception e) {
      System.out.print("getKeyWords++++++Exception");
      keyWords.put("error", e.toString());
      e.printStackTrace();
    } finally {
      try {
        this.myDelete(this.indexDir);
        this.myDelete(this.wekaFile);
      } catch (Exception e) {
        e.printStackTrace();
      }
      return keyWords;
    }
  }
Example #2
0
  /** 用户选择登陆渠道 */
  @RequestMapping("/preLogin.do")
  public void preLogin(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException, ApiException {
    String regMethod = request.getParameter("regMethod");
    if ("weibo".equalsIgnoreCase(regMethod)) { // 新浪微博登陆
      weibo4j.Oauth oauth = new weibo4j.Oauth();
      try {
        String openUrl = oauth.authorize("code", ConstatVar.WEIBO_APPKEY, ConstatVar.WEIBO_SECRET);
        response.sendRedirect(openUrl);
      } catch (weibo4j.model.WeiboException e) {
        e.printStackTrace();
        // TODO 跳转到错误页,提示用户重新选择注册渠道
      }
    } else if ("qq".equalsIgnoreCase(regMethod)) { // QQ登陆
      com.qq.connect.oauth.Oauth oauth = new com.qq.connect.oauth.Oauth();
      try {
        String openUrl = oauth.getAuthorizeURL(request);
        response.sendRedirect(openUrl);
      } catch (com.qq.connect.QQConnectException e) {
        e.printStackTrace();
        // TODO 跳转到错误页,提示用户重新选择注册渠道
      }
    } else if ("taobao".equalsIgnoreCase(regMethod)) { // Taobao登陆

      // TODO
    } else {
      response.sendRedirect("/loginPage.do");
    }
    return;
  }
 public static void main(String[] args) {
   String access_token = args[0];
   Account am = new Account(access_token);
   try {
     RateLimitStatus json = am.getAccountRateLimitStatus();
     Log.logInfo(json.toString());
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 public static void main(String[] args) {
   String access_token = args[0];
   Search search = new Search();
   search.client.setToken(access_token);
   try {
     search.searchSuggestionsUsers(args[1]);
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 public static void main(String[] args) {
   String access_token = args[0];
   Suggestion suggestion = new Suggestion(access_token);
   try {
     JSONArray jo = suggestion.suggestionsUsersMayInterested();
     System.out.println(jo.toString());
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 public static void main(String[] args) {
   String access_token = args[0];
   String nickname = args[1];
   Register reg = new Register(access_token);
   try {
     JSONObject json = reg.verifyNickname(nickname);
     System.out.println(json.toString());
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #7
0
 public static void main(String[] args) {
   String access_token = args[0];
   String city = args[1];
   Location l = new Location(access_token);
   try {
     JSONObject json = l.getMapImageByCity(city);
     Log.logInfo(json.toString());
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 public static void main(String[] args) {
   String access_token = args[0];
   String uid = args[1];
   Place p = new Place(access_token);
   try {
     StatusWapper sw = p.userPhotoList(uid);
     Log.logInfo(sw.toString());
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 public static void main(String[] args) {
   String access_token = args[0];
   String q = args[1];
   Search search = new Search(access_token);
   try {
     JSONArray jo = search.searchSuggestionsCompanies(q);
     System.out.println(jo.toString());
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 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();
   }
 }
Example #11
0
 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];
   Trend tm = new Trend(access_token);
   try {
     List<Trends> trends = tm.getTrendsHourly();
     for (Trends ts : trends) {
       Log.logInfo(ts.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #13
0
  public int GetCurrentCountInfo() {
    try {
      RateLimitStatus data = am.getAccountRateLimitStatus();
      return data.getRemainingIpHits();
    } catch (WeiboException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return 0;
    // TODO Auto-generated method stub

  }
Example #14
0
 public UserData GetUserData(String userName) {
   User userdata = null;
   try {
     userdata = um.showUserByScreenName(userName);
   } catch (WeiboException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return DataConverter.ConvertFrom(userdata);
   // TODO Auto-generated method stub
   // return null;
 }
Example #15
0
 public static void main(String[] args) {
   String access_token = args[0];
   Weibo weibo = new Weibo();
   weibo.setToken(access_token);
   String uids = args[1];
   Users um = new Users();
   try {
     JSONArray user = um.getUserCount(uids);
     Log.logInfo(user.toString());
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 public static void main(String[] args) {
   String access_token = args[0];
   Favorite fm = new Favorite(access_token);
   String tid = args[1];
   try {
     List<Favorites> favors = fm.getFavoritesByTags(tid);
     for (Favorites s : favors) {
       Log.logInfo(s.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #17
0
 public static void main(String[] args) {
   String access_token = args[0];
   Weibo weibo = new Weibo();
   weibo.setToken(access_token);
   String trend_name = args[1];
   Trend tm = new Trend();
   try {
     JSONObject result = tm.isFollow(trend_name);
     Log.logInfo(String.valueOf(result));
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #18
0
 public static void main(String[] args) {
   String access_token = args[0];
   String uid = args[1];
   Place p = new Place(access_token);
   try {
     List<Places> list = p.checkinsList(uid);
     for (Places pl : list) {
       Log.logInfo(pl.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #19
0
 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();
   }
 }
 public static void main(String[] args) {
   String access_token = args[0];
   String srcids = args[1];
   Location l = new Location(access_token);
   try {
     List<Poisition> list = l.showPoisBatch(srcids);
     for (Poisition p : list) {
       Log.logInfo(p.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
 private boolean isGz(String uid, String zhuanfazheUid) {
   String friends[] = null;
   try {
     friends = friendships.getFriendsIdsByUid(zhuanfazheUid, 2000, 0);
   } catch (WeiboException e) {
     e.printStackTrace();
   }
   for (int i = 0; i < friends.length; i++) {
     if (friends[i].equals(uid)) {
       return true;
     }
   }
   return false;
 }
Example #22
0
 public static void main(String[] args) {
   String access_token = args[0];
   String q = args[1];
   String coordinates = args[2];
   Location l = new Location(access_token);
   try {
     List<Poisition> list = l.searchPoisByAreaByQ(q, coordinates);
     for (Poisition p : list) {
       Log.logInfo(p.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #23
0
 /** @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();
   }
 }
Example #24
0
 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>();
 }
Example #25
0
 /** @param args */
 public static void main(String[] args) {
   String access_token = args[0];
   Weibo weibo = new Weibo();
   weibo.setToken(access_token);
   Tags tm = new Tags();
   String ids = args[1];
   List<Tag> tags = null;
   try {
     tags = tm.destroyTagsBatch(ids);
     for (Tag t : tags) {
       Log.logInfo(t.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #26
0
 public static void main(String[] args) {
   String access_token = args[0];
   String id = args[1];
   Friendships fm = new Friendships(access_token);
   try {
     UserWapper users = fm.getFriendsByID(id);
     for (User u : users.getUsers()) {
       System.out.println(u.toString());
     }
     System.out.println(users.getNextCursor());
     System.out.println(users.getPreviousCursor());
     System.out.println(users.getTotalNumber());
   } 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);
   String uid = args[1];
   Trend tm = new Trend();
   List<UserTrend> trends = null;
   try {
     trends = tm.getTrends(uid);
     for (UserTrend t : trends) {
       Log.logInfo(t.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #28
0
 @Test
 public void testShowTags() {
   String access_token =
       "2.00d5evFEnhnsoBc45cd025fencuzbE"; // get token code from <code>OAuth4Code.java</code>
   String uid = "2552134982";
   Tags tm = new Tags();
   tm.client.setToken(access_token);
   try {
     List<Tag> wbTags = tm.getTags(uid);
     for (Tag tag : wbTags) {
       Log.logInfo(tag.toString());
     }
   } catch (WeiboException e) {
     e.printStackTrace();
   }
 }
Example #29
0
 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();
   }
 }
Example #30
0
  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>();
  }