public FlickrPhotosExporter(AppCredentials appCredentials) { this.flickr = new Flickr(appCredentials.getKey(), appCredentials.getSecret(), new REST()); this.photosetsInterface = flickr.getPhotosetsInterface(); this.photosInterface = flickr.getPhotosInterface(); }
public com.flickr4java.flickr.Response post(String path, Map<String, Object> parameters, String apiKey, String sharedSecret, boolean multipart) throws FlickrException { OAuthRequest request = new OAuthRequest(Verb.POST, getScheme() + "://" + getHost() + path); buildMultipartRequest(parameters, request); } else { buildNormalPostRequest(parameters, request); if (auth != null) { Token requestToken = new Token(auth.getToken(), auth.getTokenSecret()); OAuthService service = createOAuthService(parameters, apiKey, sharedSecret); service.signRequest(requestToken, request); request.addPayload(buildMultipartBody(parameters, getMultipartBoundary())); request.addHeader("Proxy-Authorization", "Basic " + getProxyCredentials());
/** * Invoke an HTTP POST request on a remote host. * * @param path The request path * @param parameters The parameters (collection of Parameter objects) * @return The Response object */ @Override public com.flickr4java.flickr.Response post(String path, Map<String, Object> parameters, String apiKey, String sharedSecret) throws FlickrException { OAuthRequest request = new OAuthRequest(Verb.POST, buildUrl(path)); buildNormalPostRequest(parameters, request); OAuth10aService service = createAndSignRequest(apiKey, sharedSecret, request); try { return handleResponse(request, service); } catch (IllegalAccessException | InterruptedException | ExecutionException | InstantiationException | IOException | SAXException | ParserConfigurationException e) { throw new FlickrRuntimeException(e); } }
/** * Invoke an HTTP POST request on a remote host. * * @param path The request path * @param metaData The parameters (collection of Parameter objects) * @param payload * @return The Response object */ @Override public com.flickr4java.flickr.Response postMultiPart(String path, UploadMetaData metaData, Payload payload, String apiKey, String sharedSecret) throws FlickrException { OAuthRequest request = new OAuthRequest(Verb.POST, buildUrl(path)); Map<String, String> uploadParameters = new HashMap<>(metaData.getUploadParameters()); buildMultipartRequest(uploadParameters, request); OAuth10aService service = createAndSignRequest(apiKey, sharedSecret, request); // Ensure all parameters (including oauth) are added to payload so signature matches uploadParameters.putAll(request.getOauthParameters()); request.addMultipartPayload(String.format("form-data; name=\"photo\"; filename=\"%s\"", metaData.getFilename()), metaData.getFilemimetype(), payload.getPayload()); uploadParameters.entrySet().forEach(e -> request.addMultipartPayload(String.format("form-data; name=\"%s\"", e.getKey()), null, e.getValue().getBytes())); try { return handleResponse(request, service); } catch (IllegalAccessException | InterruptedException | ExecutionException | InstantiationException | IOException | SAXException | ParserConfigurationException e) { throw new FlickrRuntimeException(e); } }
public com.flickr4java.flickr.Response get(String path, Map<String, Object> parameters, String apiKey, String sharedSecret) throws FlickrException { OAuthRequest request = new OAuthRequest(Verb.GET, buildUrl(path)); for (Map.Entry<String, Object> entry : parameters.entrySet()) { request.addQuerystringParameter(entry.getKey(), String.valueOf(entry.getValue())); request.addHeader("Proxy-Authorization", "Basic " + getProxyCredentials()); OAuth10aService service = createOAuthService(apiKey, sharedSecret); if (auth != null) { OAuth1AccessToken requestToken = new OAuth1AccessToken(auth.getToken(), auth.getTokenSecret()); return handleResponse(request, service); } catch (IllegalAccessException | InstantiationException | SAXException | IOException | InterruptedException | ExecutionException | ParserConfigurationException e) { throw new FlickrRuntimeException(e);
public FlickrPhotosImporter(AppCredentials appCredentials, JobStore jobStore) { this.jobStore = jobStore; this.flickr = new Flickr(appCredentials.getKey(), appCredentials.getSecret(), new REST()); this.uploader = flickr.getUploader(); this.imageStreamProvider = new ImageStreamProvider(); this.photosetsInterface = flickr.getPhotosetsInterface(); }
import java.util.Collections; import com.flickr4java.flickr.Flickr; import com.flickr4java.flickr.REST; import com.flickr4java.flickr.collections.Collection; import com.flickr4java.flickr.test.TestInterface; public class hello { public static void main(String args[]){ String apiKey = "3f7046fe0897516df587cc3e6226f878"; String sharedSecret = "9d0ceef5f2f3040f"; Flickr f = new Flickr(apiKey, sharedSecret, new REST()); TestInterface testInterface = f.getTestInterface(); java.util.Collection<Element> results = testInterface.echo(Collections.EMPTY_MAP); } }
private static Flickr makeFlickr(FlickrAPIToken token) throws ParserConfigurationException { return new Flickr(token.apikey, token.secret, new REST()); } }
private static Flickr makeFlickr(FlickrAPIToken token) throws ParserConfigurationException { return new Flickr(token.apikey, token.secret, new REST()); } }
private void setUpFlickr() { try { Flickr flickr = new Flickr(flickrApiKey, flickrSecret, new REST()); flickrConnection = flickr.getPhotosInterface(); } catch (ParserConfigurationException e) { e.printStackTrace(); //Proper error handling goes here } }
/** * 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); }
Transport t = new REST(); Flickr f = new Flickr("key", "secret", t); PhotoList list = f.getPhotosetsInterface().getPhotos("setId", 100, 1); for (Iterator iterator = list.iterator(); iterator.hasNext();) { Photo photo = (Photo) iterator.next(); File file = new File("/tmp/" + photo.getId() + ".jpg"); ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write(photo.getOriginalAsStream()); FileUtils.writeByteArrayToFile(file, b.toByteArray()); }
/** * 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); }
Flickr flickr = new Flickr(API_KEY,SHARED_SECRET,new REST()); Set<String> extras = new HashSet(); // A set of extra info we want Flickr to give back. Go to the API page to see the other size options available. extras.add("url_o"); extras.add("original_format"); //A request for a list of the photos in a set. The first zero is the privacy filter, // the second is the Pages, and the third is the Per-Page (see the Flickr API) PhotoList<Photo> photoList = flickr.getPhotosetsInterface().getPhotos(PHOTOSET_ID, extras, 0, 0, 0); //We'll use the direct URL to the original size of the photo in order to download it. Remember: you want to make as few requests from flickr as possible! for(Photo photo : photoList){ //You can also get other sizes. Just ask for the info in the first request. URL url = new URL(photo.getOriginalSize().getSource()); InputStream is = url.openStream(); OutputStream os = new FileOutputStream(PATH_OF_FOLDER + photo.getTitle() + "." + photo.getOriginalFormat()); byte[] b = new byte[2048]; int length; while ((length = is.read(b)) != -1) { os.write(b, 0, length); } is.close(); os.close(); }
Flickr flickr = new Flickr("xx", "yy", new REST()); Flickr.debugStream = false; requestContext = RequestContext.getRequestContext();
@Override public void setup(ImageCollectionConfig config) throws ImageCollectionSetupException { try { final String apikey = config.read("webpage.flickr.apikey"); final String secret = config.read("webpage.flickr.secret"); flickr = new Flickr(apikey, secret, new REST(Flickr.DEFAULT_HOST)); } catch (final Exception e) { throw new ImageCollectionSetupException("Faile to setup, error creating the flickr client"); } super.setup(config); }
String apikey; String secret; // Create a Flickr instance with your data. No need to authenticate Flickr flickr = new Flickr(apikey, secret, new REST()); // Set the wanted search parameters (I'm not using real variables in the example) SearchParameters searchParameters = new SearchParameters(); searchParameters.setAccuracy(accuracyLevel); searchParameters.setBBox(minimum_longitude, minimum_latitude, maximum_longitude, maximum_latitude); PhotoList<Photo> list = flickr.getPhotosInterface().search(searchParameters, 0, 0); // Do something with the list
flickr = new Flickr(flickrKey, flickrSecret, new REST()); authInterface = flickr.getAuthInterface();
Flickr f = new Flickr(API_KEY, API_SEC, new REST()); return f; } catch (ParserConfigurationException e) {