public List<Long> GetRelationIDs(RelationType relationType, String searchinfo, int mount) { switch (relationType) { case Friend: try { return Translate(fm.getFriendsIdsByUid(searchinfo, mount, 0)); } catch (WeiboException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return new ArrayList<Long>(); } case FriendsOnBilateral: try { return Translate(fm.getFriendsBilateralIds(searchinfo, mount, 0)); } catch (WeiboException e) { // TODO Auto-generated catch block e.printStackTrace(); return new ArrayList<Long>(); } case Follows: try { return Translate(fm.getFollowersIdsById(searchinfo, mount, 0)); } catch (WeiboException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; } return new ArrayList<Long>(); }
@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; } }
/** 用户选择登陆渠道 */ @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(); } }
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(); } }
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(); } }
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 }
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; }
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(); } }
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(); } }
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(); } }
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; }
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(); } }
/** @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 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>(); }
/** @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(); } }
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(); } }
@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(); } }
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>(); }