Giter VIP home page Giter VIP logo

flickr4java's Introduction

Flickr4Java

Introduction

Note: This API has been forked from FlickrJ at Sourceforge.

This is a Java API which wraps the REST-based Flickr API.

Comments and questions should be raised on the GitHub Repo issue tracker.

Usage

To use the API just construct an instance of the class com.flickr4java.flickr.test.Flickr and request the interfaces which you need to work with.
For example, to send a test ping to the Flickr service:

String apiKey = "YOUR_API_KEY";
String sharedSecret = "YOUR_SHARED_SECRET";
Flickr f = new Flickr(apiKey, sharedSecret, new REST());
TestInterface testInterface = f.getTestInterface();
Collection results = testInterface.echo(Collections.EMPTY_MAP);

See /src/examples/java for more.

Setting User-Agent

Since version 3.0.7 Flickr4Java passes the following User-Agent header in its requests

Flickr4Java/3.x

If you want to override that and set your own you can pass in your own value. Note that no validation is performed on the provided string.

REST transport = new REST();
transport.setUserAgent("MyUserAgent/0.1");
Flickr f = new Flickr(apiKey, sharedSecret, transport);

Requirements

This API has been tested and built with JDK 1.8.

An API key is required to use this API. You can request one on Flickr.

Required libraries

See here for details on how to choose and configure an SLF4J logging library.

Gradle

compile 'com.flickr4java:flickr4java:3.0.9'

Maven

<dependency>
  <groupId>com.flickr4java</groupId>
  <artifactId>flickr4java</artifactId>
  <version>3.0.9</version>
</dependency>

Flickr4Java is available on Maven Central so the above settings should be all you need.

Testing

The tests now run against captured responses from Flickr (see src/test/resources/payloads) and don't contact the Flickr API at all.
This means there is no longer any need to create a test account and populate a properties file.

Functional testing against the Flickr API.

This is the setup to run the tests against the Flickr API.
Not for the faint-hearted. Only do this to test large refactorings etc.

Create up a setup.properties file (see src/test/resources/setup.properties.example) with details of a real account on Flickr (I recommend setting up a test account for this purpose).
Run tests as follows.

mvn -DsetupPropertiesPath=/path/to/your/setup.properties clean install

Expect lots of failures and general flakiness as data has changed on Flickr and the tests or data need updating.

Dependency checker

OWASP dependency-check is configured in the pom.xml.

To run a dependency check

mvn -U clean verify -P dependency-check

flickr4java's People

Contributors

allentiak avatar artikulant avatar boncey avatar bryancresswell avatar callmeal avatar dependabot[bot] avatar devniall avatar don-vip avatar e-penguin avatar farnulfo avatar haggisandchips avatar hugal31 avatar hytgbn avatar ihcsim avatar jjhesk avatar jonhare avatar kevinstrong avatar kewang avatar linus12 avatar mike10004 avatar perrygeorget avatar qduc avatar robfrank avatar samwilson avatar szabobalint-virgo avatar tague avatar tdmitriy avatar vermgit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flickr4java's Issues

Implement new 'Groups' methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Groups methods that need to be implemented.

  • flickr.groups.join
  • flickr.groups.joinRequest
  • flickr.groups.leave

Implement new 'Cameras' methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Cameras methods that need to be implemented.

  • flickr.cameras.getBrandModels
  • flickr.cameras.getBrands

Implement Urls API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Urls methods that need to be implemented.

flickr.urls.lookupGallery

Implement new 'Topics' methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Topics methods that need to be implemented.

  • flickr.groups.discuss.topics.add
  • flickr.groups.discuss.topics.getInfo
  • flickr.groups.discuss.topics.getList

Tidy up tests

Rough proposal to tidy up the unit tests.

  • Change to use JUnit annotations (I think I can use Rescripter (https://github.com/activelylazy/Rescripter) to take the grunt work out of this).
  • Merge common code into base classes - the code in the setup methods seems to have a lot of duplication.
  • Tidy up the use of data in properties files, document better and fail early if data is missing.

I'm happy to take this on as a low priority task.

Implement People API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the People methods that need to be implemented.

  • flickr.people.getPhotos
  • flickr.people.getPhotosOf
  • flickr.photos.people.add
  • flickr.photos.people.delete
  • flickr.photos.people.deleteCoords
  • flickr.photos.people.editCoords
  • flickr.photos.people.getList

Fix Exception handling

I think we should probably wrap up the various Exceptions thrown throughout the API into a common run time exception.

Something like:
public class Flickr4JavaException extends RuntimeException;

What do you think?

Method to check if photo is present in a set or not.

Hi,
I am new to flickr4java. Is there any method through which i can know that whether a particular photo is present in a set or not.
I am using the following code to get all photos in flickr.

  PhotosInterface Pface= flickr.getPhotosInterface();

PhotoList<Photo> PL = Pface.recentlyUpdated(thisDate, null, 0, 0);

for (int i = 0;i<PL.size();i++)
        {
    Photo p= PL.get(i);
    //Want to check if the photo p is present in a set or not.
    }       
}

Release 2 Build

I'm heading out of town, would like to do a build on Friday if possible. For completeness, this is the last missing piece (besides PushInterface).

Any issues if I do a build Friday? Is there anything you'd like to add before hand?

Java version

Just wondering what version of Java we should be supporting.

Should we stick with 1.5 as it is now?
Not sure what new features we might need from 1.6 anyway.

I think it's probably a good idea to set the compiler version correctly so we don't accidentally include some new feature.

Implement Stats API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Stats methods that need to be implemented.

  • flickr.stats.getCollectionDomains
  • flickr.stats.getCollectionReferrers
  • flickr.stats.getCollectionStats
  • flickr.stats.getCSVFiles
  • flickr.stats.getPhotoDomains
  • flickr.stats.getPhotoReferrers
  • flickr.stats.getPhotosetDomains
  • flickr.stats.getPhotosetReferrers
  • flickr.stats.getPhotosetStats
  • flickr.stats.getPhotoStats
  • flickr.stats.getPhotostreamDomains
  • flickr.stats.getPhotostreamReferrers
  • flickr.stats.getPhotostreamStats
  • flickr.stats.getPopularPhotos
  • flickr.stats.getTotalViews

Unable to upload large files

When uploading large files, a stream is passed to the API:

Flickr.getUploader().upload(InputStream, params)

However, REST.java buffers everything in to a ByteArrayOutputStream before passing it to the scribe OAuth library. Therefore, uploading large files can often cause out of memory errors (depends on the size of file and heap of course).

Scribe OAuth (as far as I know) doesn't support any streaming yet, so we could either create our own implementation, swap out for an implementation that does support this, or ask and wait for those guys to fix theirs.

I've opened an issue on Scribe related to this:

scribejava/scribejava#347

build.gradle question

in looking at the build.gradle file, I noticed the following
version = '2.2-SNAPSHOT'
group = 'com.flicr4java.flickr'

It appears the group name has a spelling error (missing k in flicr4java.flickr), is it supposed to be this way or is it a typo ?

Implement Collections API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Collections methods that need to be implemented.

  • flickr.collections.getInfo
  • flickr.collections.getTree

Implement Photosets API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Photosets methods that need to be implemented.

  • flickr.photosets.removePhotos
  • flickr.photosets.reorderPhotos
  • flickr.photosets.setPrimaryPhoto

JUnit - Copied Code

Most JUnit tests have the exact same code in setUp. I created a super class, Flickr4JavaTest, if the setUp is the same then it can be superclassed and the setUp method removed, so any defect fixes to the super will be made in one place.

Tests are a pain to maintain

Having just run the tests for the first time in a while I had a lot of trouble getting them to pass.

This is mainly because they rely on "live" data on Flickr.
Naturally a bunch of my stuff had changed so I needed to edit the tests (whilst also trying to not make them specific to my data).
There were also other issues:

  • My token didn't have delete privileges so the test couldn't delete the photos it had uploaded.
  • The user needs to be a Pro account for some API calls so using a free dummy account doesn't work very well.

Not sure what the solution is to this problem is but here are some ideas.

Split the tests up

Split the tests into dev tests that stub out the Flickr API and integration tests that hit the live API with the caveat that they will only pass if you have data in a certain state.
Stubbing out the Flickr API is obviously a lot of work though - though I wonder if there's a clever way to generate that stub from the Flickr reflection call.

Reduce what's tested

We could reduce the amount of stuff that's being tested and/or make it less strict - eg, rather than check a photo has ten favourites, just check it has at least one etc.

Any other ideas?

getGroups throws an error

It appears a call to getGroups for both PeopleInterface and the PoolsInterface is nor problematic I get:
[Fatal Error] :1:1: Content is not allowed in prolog.

The code to do this is:

                REST rest = new REST();
        rest.setHost("www.flickr.com");

        Flickr flickr = new Flickr(apiKey, secret, rest);

        Auth auth = new Auth();
        auth.setPermission(Permission.READ);
        auth.setToken(myToken);
        auth.setTokenSecret(myTokenSecret);

        RequestContext requestContext = RequestContext.getRequestContext();
        requestContext.setAuth(auth);
        flickr.setAuth(auth);

        PeopleInterface iface = flickr.getPeopleInterface();
        Collection<Group> groups = iface.getGroups(userId);

2 additional sizes: 1600 and 2048

It would be nice if flickr4java would know 2 more sizes: something like

LARGE2048 and LARGE1600

so that PhotosInterface.getSizes(String aPhotoId) would work properly.

1024 often is too small but the original size might be too big, so 1600 and 2048 are (imho) somehow handy sizes and actually i would require it.

I started to add that here, but it is not yet working ...
... and if there is somebody who already added other sizes ... he might implement that fast and without errors.

i'm looking forward for a feedback.
maybe i could help doing it.

(but at time i'm struggling with the fact that the project is not building with maven ... which is another problem ... and which i already noted to some of the developpers)

Build borked

The build seems to be borked. It looks like some sort of merge problem. For example:

[javac] Flickr4Java/src/com/flickr4java/flickr/cameras/CamerasInterface.java:288: error: class, interface, or enum expected
    [javac] import java.util.Map;
    [javac] ^
    [javac] 100 errors
    [javac] 1 warning

And the file does indeed look weird:

}
>>>>>>> 8080af10a7f34bdce972d0e96765084e14e113f0
=======
/**
 * @author acaplan
 */
package com.flickr4java.flickr.cameras;

import java.util.ArrayList;

Hope it wasn't my fault! :)

Implement new 'Replies' methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Replies methods that need to be implemented.

  • flickr.groups.discuss.replies.add
  • flickr.groups.discuss.replies.delete
  • flickr.groups.discuss.replies.edit
  • flickr.groups.discuss.replies.getInfo
  • flickr.groups.discuss.replies.getList

Compiled version

Hello. I think a compiled version of this library would make it easier for people to import it. Would that be possible?

Collections

There's a lot of classes like PhotoList which seem to be just a way to make a list typesafe. We can do this in 1.5 with Generics. It could mean anyone using these in their code would need to re-code but it would be a very small change. More specifically, probrably change to SearchResultList, which does have use as far as pagnation goes

Consider moving from Ant to Maven or Gradle?

Would you consider moving this project from Ant to Maven or Gradle?

The main advantages are of course:

  • Dependency management (instead of lib folders)
  • Convention over configuration

I only really care about the second advantage for my own projects as I don't really have to read/write the build.xml in this project. The first one is quite important for me because I'd like to consume Flickr4Java in Groovy scripts using Grapes. Groovy scripts are distributed as single files (normally), so being able to pull down Flickr4Java and its dependencies from Maven central (for example) would be very nice.

Of course, if Flickr4Java was published to Maven Central using some other mechanism, I guess I wouldn't care that much :)

Anyway, if this is something you'd consider, I'd be happy to give it a go and issue a pull request. It looks likes the Flick4Java build is pretty simple.

I'd prefer Gradle because it understands that humans don't speak XML and that build scripts need to contain code sometimes, but Maven is good too.

Simple getImageInfo

Hi,

I am trying to get the info of some image passing photo_id but The code dont run.

PhotosInterface photoInterface = new PhotosInterface(flickrConsumerKey, flickrConsumerSecret, new REST());
try {
com.flickr4java.flickr.photos.Photo photo = photoInterface.getPhoto(photoId);
} catch (FlickrException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

this method getPhoto, call getInfo which I need to passing secret (optional).
how can I call this method, I just want the Info about some image

Flickr API: Re-Brand

Need to re-brand licensing, code etc from FlickrJ. This must maintain the references required by FlickrJ's license agreement

tag without space

Hi,

I met a problem when using the tag interface like:

Photo e=flickr.getPhotosInterface().getPhoto("8629684094");
for(Tag g:e.getTags())
{ System.out.println(g.getValue());}

When the tag contains only one word, it works fine. But if it contains more than one word, it returns a string without space. For example, for the photo: http://www.flickr.com/photos/xaviersam/8629684094/, it contains a tag: "hitech filter", but the above code returns "hitechfilter".

I want the function to return a tag with space, can you give some advice?

Thanks very much

SOAP Functionality

This isn't working currently, get SOAP working and make sure JUnit tests are running

Implement Galleries API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Galleries methods that need to be implemented.

  • flickr.galleries.addPhoto
  • flickr.galleries.create
  • flickr.galleries.editMeta
  • flickr.galleries.editPhoto
  • flickr.galleries.editPhotos
  • flickr.galleries.getInfo
  • flickr.galleries.getList
  • flickr.galleries.getListForPhoto
  • flickr.galleries.getPhotos

Implement Favorites API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Favorites methods that need to be implemented.

  • flickr.favorites.getContext

Implement PhotosetsComments API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the PhotosetsComments methods that need to be implemented.

  • flickr.photosets.comments.addComment
  • flickr.photosets.comments.deleteComment
  • flickr.photosets.comments.editComment
  • flickr.photosets.comments.getList

Sort out downloads/releases

The github downloads page is now deprecated.
They no longer allow hosting of zip files etc.

They encourage us to use the 'zip' button on the project home page that downloads the latest version.
I've updated the README to use that link now.

However, if we want to do releases and publish to mvnrepository.com we'll need a place to host our versioned releases.

The Maven Guide to uploading artifacts to the Central Repository says to use the Sonatype OSS Repository which seems to be free.

I'll investigate getting a release hosted there first.

Code formatting

I'm quite a fan of letting my IDE format my code for me whenever I save changes.

Do you object to me making some code formatting rules for Eclipse then applying them to all the code?

It would be broadly in line with how the code is laid out now - same bracing styles and indentation etc.
I'm just too lazy to do all this by hand when I write code. :-)

I can then check in the formatting rules for everyone else to use locally too.

Still about tags of one user

Hi,

thanks for the update of flickr.getTagsInterface().getListUserRaw.

But the following code still returns: "com.flickr4java.flickr.FlickrException: 1: User not found":
for (TagRaw c: flickr.getTagsInterface().getListUserRaw("UserId")){..........}

it may track back in TagsInterface.java, line 367:
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());

so there is something wrong in
Response response = transportAPI.get(transportAPI.getPath(), parameters, sharedSecret);

I think the problem happens somewhere in defining METHOD_GET_LIST_USER_RAW. I happened to modify line 355: parameters.put("method", METHOD_GET_LIST_USER_RAW); to the following code:
parameters.put("method", METHOD_GET_LIST_USER);
the error disappear but c.getRaw() returns many "null"s.

I am not familiar with HashMap or Map class and have no idea how to debug further.

Any suggestions?

unsupported element name: count

Hi,
I'm developing a flickr group tool for group admins and am using flickr4java

In PoolsInterface.java
public PhotoContext getContext(String photoId, String groupId)

the element "count" is not handled, instead I get a
"unsupported element name: count"

... which is pretty anoying, because i get thaousands of it ... ;)
It took me a while to find the origin of that
the error message isn*t really a useful hint from where its coming.

In fact, regarding flickrapi docs, no element "count" is delivered, as shown here:
https://secure.flickr.com/services/api/flickr.photos.getContext.html

Moreover, if I patch PoolsInterface#getContext, to
System.out.println("count: " + element.getAttribute("count"));

there is no value printed :(
I think its an issue in the flickrapi, but although I could patch the class, maybe you consider to implement a way for your users, to suppress this message? I'd highly appreciate ;)

anyway, thank you for the great work!
regards

  • nik (flickr.com/photos/nixart)

Implement Push API methods

There's a test (CompletenessTest) that interrogates the API and lists methods we've not implemented yet.
I'm gonna raise separate issues for each thing that needs implementing which will make it easier to split the work.

These are the Push methods that need to be implemented.

  • flickr.push.getSubscriptions
  • flickr.push.getTopics
  • flickr.push.subscribe
  • flickr.push.unsubscribe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.