private void act(String suggestionId, String method) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", method); parameters.put("suggestion_id", suggestionId); Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
public void editPhotos(String strGalleryId, String strPrimaryPhotoId, String strPhotoIds) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_EDIT_PHOTOS); parameters.put("gallery_id", strGalleryId); parameters.put("primary_photo_id", strPrimaryPhotoId); parameters.put("photo_ids", strPhotoIds); Response response = transport.post(transport.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
/** * Construct an Uploader. * * @param apiKey * The API key */ public Uploader(String apiKey, String sharedSecret) { this(apiKey, sharedSecret, new REST(Transport.UPLOAD_API_HOST)); this.transport.setResponseClass(UploaderResponse.class); }
/** * * @param authToken * The authentication token * @param tokenSecret * @return The Auth object * @throws FlickrException * @see "http://www.flickr.com/services/api/flickr.auth.oauth.checkToken.html" */ public Auth checkToken(String authToken, String tokenSecret) throws FlickrException { // Use TreeMap so keys are automatically sorted alphabetically Map<String, String> parameters = new TreeMap<String, String>(); parameters.put("method", METHOD_CHECK_TOKEN); parameters.put("oauth_token", authToken); parameters.put(Flickr.API_KEY, apiKey); // This method call must be signed using Flickr (not OAuth) style signing parameters.put("api_sig", getSignature(sharedSecret, parameters)); Response response = transportAPI.getNonOAuth(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } Auth auth = constructAuth(response, authToken, tokenSecret); return auth; }
private String sendUploadRequest(UploadMetaData metaData, Payload payload) throws FlickrException { UploaderResponse response = (UploaderResponse) transport.postMultiPart(SERVICES_UPLOAD_PATH, metaData, payload, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } return getResponseString(metaData.isAsync(), response); }
/** * Invoke an HTTP POST request on a remote host. * * @param path * The request path * @param parameters * The parameters (List of Parameter objects) * @param apiKey * @param sharedSecret * @return The Response object * @throws FlickrException */ public Response post(String path, Map<String, Object> parameters, String apiKey, String sharedSecret) throws FlickrException { return post(path, parameters, apiKey, sharedSecret, false); }
/** * * @param authToken * The authentication token * @param tokenSecret * @return The Auth object * @throws FlickrException * @see "http://www.flickr.com/services/api/flickr.auth.oauth.checkToken.html" */ public Auth checkToken(String authToken, String tokenSecret) throws FlickrException { // Use TreeMap so keys are automatically sorted alphabetically Map<String, String> parameters = new TreeMap<String, String>(); parameters.put("method", METHOD_CHECK_TOKEN); parameters.put("oauth_token", authToken); parameters.put(Flickr.API_KEY, apiKey); // This method call must be signed using Flickr (not OAuth) style signing parameters.put("api_sig", getSignature(sharedSecret, parameters)); Response response = transportAPI.getNonOAuth(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } Auth auth = constructAuth(response, authToken, tokenSecret); return auth; }
private String sendReplaceRequest(boolean async, Payload payload) throws FlickrException { UploaderResponse response = (UploaderResponse) transport.postMultiPart(SERVICES_REPLACE_PATH, UploadMetaData.replace(async, payload.getPhotoId()), payload, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } return getResponseString(async, response); }
/** * Call the post multipart end point. * * @param parameters * @param path * @return * @throws FlickrException */ private UploaderResponse postPhoto(Map<String, Object> parameters, String path) throws FlickrException { UploaderResponse response = (UploaderResponse) transport.post(path, parameters, apiKey, sharedSecret, true); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } return response; }
private void act(String suggestionId, String method) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", method); parameters.put("suggestion_id", suggestionId); Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
public void addPhoto(String strGalleryId, String photoId, String strComment) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_ADD_PHOTO); parameters.put("gallery_id", strGalleryId); parameters.put("photo_id", photoId); parameters.put("comment", strComment); Response response = transport.post(transport.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
/** * Exchange an auth token from the old Authentication API, to an OAuth access token. * * Calling this method will delete the auth token used to make the request. * * @param authToken * @throws FlickrException * @see "http://www.flickr.com/services/api/flickr.auth.oauth.getAccessToken.html" */ public Token exchangeAuthToken(String authToken) throws FlickrException { // Use TreeMap so keys are automatically sorted alphabetically Map<String, String> parameters = new TreeMap<String, String>(); parameters.put("method", METHOD_EXCHANGE_TOKEN); parameters.put(Flickr.API_KEY, apiKey); // This method call must be signed using Flickr (not OAuth) style signing parameters.put("api_sig", getSignature(sharedSecret, parameters)); Response response = transportAPI.getNonOAuth(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } Token accessToken = constructToken(response); return accessToken; }
/** * Construct an Uploader. * * @param apiKey * The API key */ public Uploader(String apiKey, String sharedSecret) { this(apiKey, sharedSecret, new REST(Transport.UPLOAD_API_HOST)); this.transport.setResponseClass(UploaderResponse.class); }
/** * Null test. This method requires authentication with 'read' permission. * * @throws FlickrException */ public void null_() throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_NULL); Response response = transport.get(transport.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
public void editPhoto(String strGalleryId, String strPhotoId, String strComment) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_EDIT_PHOTO); parameters.put("gallery_id", strGalleryId); parameters.put("photo_id", strPhotoId); parameters.put("comment", strComment); Response response = transport.post(transport.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
/** * Exchange an auth token from the old Authentication API, to an OAuth access token. * * Calling this method will delete the auth token used to make the request. * * @param authToken * @throws FlickrException * @see "http://www.flickr.com/services/api/flickr.auth.oauth.getAccessToken.html" */ public OAuth1RequestToken exchangeAuthToken(String authToken) throws FlickrException { // Use TreeMap so keys are automatically sorted alphabetically Map<String, String> parameters = new TreeMap<String, String>(); parameters.put("method", METHOD_EXCHANGE_TOKEN); parameters.put(Flickr.API_KEY, apiKey); // This method call must be signed using Flickr (not OAuth) style signing parameters.put("api_sig", getSignature(sharedSecret, parameters)); Response response = transportAPI.getNonOAuth(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } OAuth1RequestToken accessToken = constructToken(response); return accessToken; }
/** * Null test. This method requires authentication with 'read' permission. * * @throws FlickrException */ public void null_() throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_NULL); Response response = transport.get(transport.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
public void editMeta(String strGalleryId, String strTitle, String strDescription) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_EDIT_META); parameters.put("title", strTitle); parameters.put("description", strDescription); Response response = transport.post(transport.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
/** * Delete the person from the photo * * @param photoId * @param userId * @throws FlickrException */ public void delete(String photoId, String userId) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_DELETE); parameters.put("photo_id", photoId); parameters.put("user_id", userId); Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }
public void editMeta(String strGalleryId, String strTitle, String strDescription) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("method", METHOD_EDIT_META); parameters.put("title", strTitle); parameters.put("description", strDescription); Response response = transport.post(transport.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } }