Ejemplo n.º 1
0
	public Boolean addFeedUser(String sessionKey,String token){
		RenrenApiClient apiClient = RenrenApiClient.getInstance();
		JSONArray feedInfo = new JSONArray();
		String renrenUserId;
		try {
			
			renrenUserId = String.valueOf(apiClient.getUserService().getLoggedInUser(new AccessToken(sessionKey)));
		} catch (Exception err){
			err.printStackTrace();
			return false;
		}
		try {
			feedInfo = apiClient.getFeedService().getFeed("10", Integer.parseInt(renrenUserId), 1, 30,new AccessToken(sessionKey)); //可能拿不到
		} catch (Exception err){
			err.printStackTrace();
			return false;
		}
		Set<String>	messages = new HashSet<String>();
		if (feedInfo != null && feedInfo.size()>0) {
			for (int i=0;i<feedInfo.size();i++)
			{
				JSONObject currentFeed = (JSONObject) feedInfo.get(i);
				assert (currentFeed != null);
				String message = (String) currentFeed.get("message");
				messages.add(message);		
			}
		}
		UserSpace t = new UserSpace(sessionKey,renrenUserId,messages,token);
		if (!up.offer(t)) return false;
		ApiInitListener.User.put(config.properties.irt.getUserIdByToken(token),t);
		
		return true;
	}
Ejemplo n.º 2
0
	public void run()
	{
		RenrenApiClient apiClient = RenrenApiClient.getInstance();
		int defaultsleeptime = 100000;
		int sleeptime = defaultsleeptime;
			while (true) {
				try{
					getInfo(apiClient);
					sleeptime = defaultsleeptime;
					Thread.sleep(sleeptime);
				} catch(Exception e) {
					sleeptime = sleeptime * 2;
				}	
		}
	}