@Test public void testGetPhotosStringSetOfStringIntIntInt() throws IOException, FlickrException, JSONException { Photoset photoset = f.getPhotosetsInterface().getPhotos(PHOTOSET_ID, null, -1, 10, 1); assertNotNull(photoset); assertFalse(photoset.getPhotoList().isEmpty()); }
public Photoset getPhotos(String photosetId, Set<String> extras, int privacyFilter, int perPage, int page) throws IOException, FlickrException, JSONException { PhotoList photos = new PhotoList(); List<Parameter> parameters = new ArrayList<Parameter>(); parameters.add(new Parameter("method", METHOD_GET_PHOTOS)); boolean signed = OAuthUtils.hasSigned(); if (signed) { parameters.add(new Parameter( OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey)); } else { parameters.add(new Parameter("api_key", apiKey)); } parameters.add(new Parameter("photoset_id", photosetId)); if (perPage > 0) { parameters.add(new Parameter("per_page", new Integer(perPage))); } if (page > 0) { parameters.add(new Parameter("page", new Integer(page))); } if (privacyFilter > 0) { parameters.add(new Parameter("privacy_filter", "" + privacyFilter)); } if (extras != null && !extras.isEmpty()) { parameters.add(new Parameter(Extras.KEY_EXTRAS, StringUtilities .join(extras, ","))); } if (signed) { OAuthUtils.addOAuthToken(parameters); } Response response = signed ? transportAPI.postJSON(sharedSecret, parameters) : transportAPI.get(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } JSONObject photosetElement = response.getData().getJSONObject( "photoset"); Photoset photoset = parsePhotoset(photosetElement); photoset.setPhotoList(photos); JSONArray photoElements = photosetElement.optJSONArray("photo"); photos.setPage(photosetElement.getString("page")); photos.setPages(photosetElement.getString("pages")); photos.setPerPage(photosetElement.getString("per_page")); photos.setTotal(photosetElement.getString("total")); for (int i = 0; photoElements != null && i < photoElements.length(); i++) { JSONObject photoElement = photoElements.getJSONObject(i); Photo photo = PhotoUtils.createPhoto(photoElement); if (photo.isPrimary()) { photoset.setPrimaryPhoto(photo); } photos.add(photo); } photoset.setPhotoCount(photos.getTotal()); return photoset; }
PhotosetsInterface { public Photoset getPhotos(String photosetId, Set<String> extras, int privacyFilter, int perPage, int page) throws IOException, FlickrException, JSONException { PhotoList photos = new PhotoList(); List<Parameter> parameters = new ArrayList<Parameter>(); parameters.add(new Parameter("method", METHOD_GET_PHOTOS)); boolean signed = OAuthUtils.hasSigned(); if (signed) { parameters.add(new Parameter( OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey)); } else { parameters.add(new Parameter("api_key", apiKey)); } parameters.add(new Parameter("photoset_id", photosetId)); if (perPage > 0) { parameters.add(new Parameter("per_page", new Integer(perPage))); } if (page > 0) { parameters.add(new Parameter("page", new Integer(page))); } if (privacyFilter > 0) { parameters.add(new Parameter("privacy_filter", "" + privacyFilter)); } if (extras != null && !extras.isEmpty()) { parameters.add(new Parameter(Extras.KEY_EXTRAS, StringUtilities .join(extras, ","))); } if (signed) { OAuthUtils.addOAuthToken(parameters); } Response response = signed ? transportAPI.postJSON(sharedSecret, parameters) : transportAPI.get(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } JSONObject photosetElement = response.getData().getJSONObject( "photoset"); Photoset photoset = parsePhotoset(photosetElement); photoset.setPhotoList(photos); JSONArray photoElements = photosetElement.optJSONArray("photo"); photos.setPage(photosetElement.getString("page")); photos.setPages(photosetElement.getString("pages")); photos.setPerPage(photosetElement.getString("per_page")); photos.setTotal(photosetElement.getString("total")); for (int i = 0; photoElements != null && i < photoElements.length(); i++) { JSONObject photoElement = photoElements.getJSONObject(i); Photo photo = PhotoUtils.createPhoto(photoElement); if (photo.isPrimary()) { photoset.setPrimaryPhoto(photo); } photos.add(photo); } photoset.setPhotoCount(photos.getTotal()); return photoset; } }
PhotosetsInterface { public Photoset getPhotos(String photosetId, Set<String> extras, int privacyFilter, int perPage, int page) throws IOException, FlickrException, JSONException { PhotoList photos = new PhotoList(); List<Parameter> parameters = new ArrayList<Parameter>(); parameters.add(new Parameter("method", METHOD_GET_PHOTOS)); boolean signed = OAuthUtils.hasSigned(); if (signed) { parameters.add(new Parameter( OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey)); } else { parameters.add(new Parameter("api_key", apiKey)); } parameters.add(new Parameter("photoset_id", photosetId)); if (perPage > 0) { parameters.add(new Parameter("per_page", new Integer(perPage))); } if (page > 0) { parameters.add(new Parameter("page", new Integer(page))); } if (privacyFilter > 0) { parameters.add(new Parameter("privacy_filter", "" + privacyFilter)); } if (extras != null && !extras.isEmpty()) { parameters.add(new Parameter(Extras.KEY_EXTRAS, StringUtilities .join(extras, ","))); } if (signed) { OAuthUtils.addOAuthToken(parameters); } Response response = signed ? transportAPI.postJSON(sharedSecret, parameters) : transportAPI.get(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } JSONObject photosetElement = response.getData().getJSONObject( "photoset"); Photoset photoset = parsePhotoset(photosetElement); photoset.setPhotoList(photos); JSONArray photoElements = photosetElement.optJSONArray("photo"); photos.setPage(photosetElement.getString("page")); photos.setPages(photosetElement.getString("pages")); photos.setPerPage(photosetElement.getString("per_page")); photos.setTotal(photosetElement.getString("total")); for (int i = 0; photoElements != null && i < photoElements.length(); i++) { JSONObject photoElement = photoElements.getJSONObject(i); Photo photo = PhotoUtils.createPhoto(photoElement); if (photo.isPrimary()) { photoset.setPrimaryPhoto(photo); } photos.add(photo); } photoset.setPhotoCount(photos.getTotal()); return photoset; } PhotosetsInterface(String apiKey, String sharedSecret,
			Transport transportAPI); }
PhotosetsInterface { public Photoset getPhotos(String photosetId, Set<String> extras, int privacyFilter, int perPage, int page) throws IOException, FlickrException, JSONException { PhotoList photos = new PhotoList(); List<Parameter> parameters = new ArrayList<Parameter>(); parameters.add(new Parameter("method", METHOD_GET_PHOTOS)); boolean signed = OAuthUtils.hasSigned(); if (signed) { parameters.add(new Parameter( OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey)); } else { parameters.add(new Parameter("api_key", apiKey)); } parameters.add(new Parameter("photoset_id", photosetId)); if (perPage > 0) { parameters.add(new Parameter("per_page", new Integer(perPage))); } if (page > 0) { parameters.add(new Parameter("page", new Integer(page))); } if (privacyFilter > 0) { parameters.add(new Parameter("privacy_filter", "" + privacyFilter)); } if (extras != null && !extras.isEmpty()) { parameters.add(new Parameter(Extras.KEY_EXTRAS, StringUtilities .join(extras, ","))); } if (signed) { OAuthUtils.addOAuthToken(parameters); } Response response = signed ? transportAPI.postJSON(sharedSecret, parameters) : transportAPI.get(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } JSONObject photosetElement = response.getData().getJSONObject( "photoset"); Photoset photoset = parsePhotoset(photosetElement); photoset.setPhotoList(photos); JSONArray photoElements = photosetElement.optJSONArray("photo"); photos.setPage(photosetElement.getString("page")); photos.setPages(photosetElement.getString("pages")); photos.setPerPage(photosetElement.getString("per_page")); photos.setTotal(photosetElement.getString("total")); for (int i = 0; photoElements != null && i < photoElements.length(); i++) { JSONObject photoElement = photoElements.getJSONObject(i); Photo photo = PhotoUtils.createPhoto(photoElement); if (photo.isPrimary()) { photoset.setPrimaryPhoto(photo); } photos.add(photo); } photoset.setPhotoCount(photos.getTotal()); return photoset; } PhotosetsInterface(String apiKey, String sharedSecret,
			Transport transportAPI); void addPhoto(String photosetId, String photoId); Photoset create(String title, String description,
			String primaryPhotoId); void delete(String photosetId); void editMeta(String photosetId, String title, String description); void editPhotos(String photosetId, String primaryPhotoId,
			String[] photoIds); PhotoContext getContext(String photoId, String photosetId); Photoset getInfo(String photosetId); Photosets getList(String userId); Photosets getList(String userId, int perPage, int page); Photoset getPhotos(String photosetId, Set<String> extras,
			int privacyFilter, int perPage, int page); Photoset getPhotos(String photosetId, int perPage, int page); void orderSets(String[] photosetIds); void removePhoto(String photosetId, String photoId); }
PhotosetsInterface { public Photoset getPhotos(String photosetId, Set<String> extras, int privacyFilter, int perPage, int page) throws IOException, FlickrException, JSONException { PhotoList photos = new PhotoList(); List<Parameter> parameters = new ArrayList<Parameter>(); parameters.add(new Parameter("method", METHOD_GET_PHOTOS)); boolean signed = OAuthUtils.hasSigned(); if (signed) { parameters.add(new Parameter( OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey)); } else { parameters.add(new Parameter("api_key", apiKey)); } parameters.add(new Parameter("photoset_id", photosetId)); if (perPage > 0) { parameters.add(new Parameter("per_page", new Integer(perPage))); } if (page > 0) { parameters.add(new Parameter("page", new Integer(page))); } if (privacyFilter > 0) { parameters.add(new Parameter("privacy_filter", "" + privacyFilter)); } if (extras != null && !extras.isEmpty()) { parameters.add(new Parameter(Extras.KEY_EXTRAS, StringUtilities .join(extras, ","))); } if (signed) { OAuthUtils.addOAuthToken(parameters); } Response response = signed ? transportAPI.postJSON(sharedSecret, parameters) : transportAPI.get(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } JSONObject photosetElement = response.getData().getJSONObject( "photoset"); Photoset photoset = parsePhotoset(photosetElement); photoset.setPhotoList(photos); JSONArray photoElements = photosetElement.optJSONArray("photo"); photos.setPage(photosetElement.getString("page")); photos.setPages(photosetElement.getString("pages")); photos.setPerPage(photosetElement.getString("per_page")); photos.setTotal(photosetElement.getString("total")); for (int i = 0; photoElements != null && i < photoElements.length(); i++) { JSONObject photoElement = photoElements.getJSONObject(i); Photo photo = PhotoUtils.createPhoto(photoElement); if (photo.isPrimary()) { photoset.setPrimaryPhoto(photo); } photos.add(photo); } photoset.setPhotoCount(photos.getTotal()); return photoset; } PhotosetsInterface(String apiKey, String sharedSecret,
			Transport transportAPI); void addPhoto(String photosetId, String photoId); Photoset create(String title, String description,
			String primaryPhotoId); void delete(String photosetId); void editMeta(String photosetId, String title, String description); void editPhotos(String photosetId, String primaryPhotoId,
			String[] photoIds); PhotoContext getContext(String photoId, String photosetId); Photoset getInfo(String photosetId); Photosets getList(String userId); Photosets getList(String userId, int perPage, int page); Photoset getPhotos(String photosetId, Set<String> extras,
			int privacyFilter, int perPage, int page); Photoset getPhotos(String photosetId, int perPage, int page); void orderSets(String[] photosetIds); void removePhoto(String photosetId, String photoId); static final String METHOD_ADD_PHOTO; static final String METHOD_CREATE; static final String METHOD_DELETE; static final String METHOD_EDIT_META; static final String METHOD_EDIT_PHOTOS; static final String METHOD_GET_CONTEXT; static final String METHOD_GET_INFO; static final String METHOD_GET_LIST; static final String METHOD_GET_PHOTOS; static final String METHOD_ORDER_SETS; static final String METHOD_REMOVE_PHOTO; }