Пример #1
0
 private Map<String, Object> grabber(String userId, JSONObject responseJson) {
   JSONArray photos = JsonUtil.getArray(responseJson, "photos");
   Map<String, Object> photoIdOwnerIdTagsMap = new HashMap<String, Object>();
   int photosNum = 0;
   if (photos != null && photos.size() != 0) {
     for (int i = 0; i < photos.size(); i++) {
       photosNum++;
       JSONObject photo = (JSONObject) photos.get(i);
       String photoOwnerId = JsonUtil.getString(photo, "user_id");
       String imgUrl = JsonUtil.getString(photo, "pic640x480");
       String photoId = (String) photo.get("id");
       JSONObject currentTag = getUserMarkFromPhoto(userId, photoId);
       if (currentTag != null) {
         Map<String, Object> additionMap = new HashMap<String, Object>();
         additionMap.put("photoOwner", photoOwnerId);
         additionMap.put("tag", currentTag);
         photoIdOwnerIdTagsMap.put(photoId, additionMap);
       }
       loadImage(imgUrl, userId, photoId);
     }
   }
   photoIdOwnerIdTagsMap.put("photosNum", photosNum);
   return photoIdOwnerIdTagsMap;
 }
Пример #2
0
 private List<String> getUserAlbumIds(String userId) {
   try {
     OdklRequest request =
         api.createApiRequest("photos", "getAlbums")
             .addParam("fid", userId)
             .addParam("count", "100");
     JSONObject responseJson = JsonUtil.parseObject(api.sendRequest(request));
     JSONArray albumArray = JsonUtil.getArray(responseJson, "albums");
     List<String> albumIds = new ArrayList<String>();
     for (int i = 0; i < albumArray.size(); i++) {
       JSONObject album = (JSONObject) albumArray.get(i);
       albumIds.add(JsonUtil.getString(album, "aid"));
     }
     return albumIds;
   } catch (OdklApiRuntimeException e) {
     if (LOGS) {
       System.out.println(
           String.format(
               "[ERR][uid%s] Runtime error while loading user albums list. Connection failed.",
               userId));
     }
   }
   return null;
 }
Пример #3
0
 private String getPhotoUrl(String photoId) {
   OdklRequest request =
       api.createApiRequest("photos", "getPhotoInfo").addParam("photo_id", photoId);
   JSONObject responseJson = JsonUtil.parseObject(api.sendRequest(request));
   return JsonUtil.getString(((JSONObject) responseJson.get("photo")), "pic640x480");
 }