views:

151

answers:

3

I'm making an authenticated call to access photos through Flickr API. But I am only getting my public photos but not any private photos.

Given below is the code I'm using,

Flickr f; RequestContext requestContext; String frob = ""; String token = "";

DocumentBuilder xmlParser = null;

public void getImages() throws ParserConfigurationException, IOException, SAXException, FlickrException, URISyntaxException, NoSuchAlgorithmException {

DocumentBuilderFactory dcb = DocumentBuilderFactory.newInstance(); try { this.xmlParser = dcb.newDocumentBuilder(); } catch (ParserConfigurationException ex) { ex.printStackTrace(); }

f = new Flickr("199d038ad88f6c6c377a4ab2341fb60f","4583b2386d3d6439",new REST()) ; Flickr.debugStream = false; requestContext = RequestContext.getRequestContext(); AuthInterface authInterface = f.getAuthInterface(); //PeopleInterface peopleInterface = f.getPeopleInterface();

try { frob = authInterface.getFrob(); } catch (FlickrException e) { e.printStackTrace(); } System.out.println("frob: " + frob);

java.net.URL url =authInterface.buildAuthenticationUrl(Permission.READ, frob);

System.out.println(url.toExternalForm());

Desktop desktop = Desktop.getDesktop(); desktop.browse(url.toURI());

// Get the response Auth auth = null ; String aLine = "";

while(aLine.equals("")) {

java.io.DataInputStream in = new java.io.DataInputStream(System.in); aLine = in.readLine();

}

auth =authInterface.getToken(frob); System.out.println("auth = "+auth); requestContext = RequestContext.getRequestContext(); requestContext.setAuth(auth); f.setAuth(auth);

UrlsInterface urlsInterface = f.getUrlsInterface(); PhotosInterface photosInterface = f.getPhotosInterface();

SearchParameters searchParams=new SearchParameters(); searchParams.setSort(SearchParameters.INTERESTINGNESS_DESC);

 //Execute search with entered tags

 searchParams.setUserId(auth.getUser().getId());


 PhotoList photoList=photosInterface.search(searchParams, 10,1);


 if(photoList!=null){
    //Get search result and check the size of photo result
    for(int i=0;i<photoList.size();i++){
        Photo photo=(Photo)photoList.get(i);

       System.out.println(photo.getSmallSquareUrl());

    }

 }
A: 

I don't know if this will help you, but I was having a similar problem with seeing only public photos and have since got it working.

I'd downloaded the flickrapi-1.2.zip from: http://sourceforge.net/projects/flickrj/files/ and was using flickrapi-1.2.jar in my webapp.

Flickr.debugRequest was showing the GET request, but it never included "auth_token", "api_sig", etc. parameters that AuthInterface checkToken (for example) successfully forces on the request.

Anyway, so just today I downloaded the source from:

flickrj.cvs.sourceforge.net/flickrj/

(You can see the revision history at: flickrj.cvs.sourceforge.net/viewvc/flickrj/api/build.properties?view=log if you're interested.)

I built the jar locally, included that in the web app and could see private photos.

I haven't spent the time to investigate further about what the exact problem was...need to use it for something :)

I don't know if that will help you, but that find is the only thing separating me from insanity.

gcbound
A: 

Hi!

I am having the same problem! Do not receive private photo sets. Downloaded API from http://sourceforge.net/projects/flickrj/files/ built it. Replaced the jar but it did not help. When debugging I see that auth_token is not included in GET. May I ask you to share your flickrj.jar with me?

Thank you!

Hi, try the approach given in this link - http://kumaripaba.blogspot.com/2010/10/how-to-access-private-photos-through.html
Kumaripaba
A: 

I managed to solve this problem by following a different approach.

This is how i solved this. Instead of using the GET method I used the getList method in photoSetsInterface (photoSetsInterface.getList(auth.getUser().getId()).getPhotosets()) .For this method you can pass the auth_token as an input parameter. Therefore it gives you all the photo sets. Then I took each photoset and retrived images under all privacy levels.

And then you can take all the photos that are not in a set by using the getNotInSet method in PhotosInterface. getNotInSet method returns all the photos not in a set regardless of the privacy level.

You can find the sample code in my blog.

Kumaripaba