如何通过Flickrj Api访问私人照片?

Pab*_*aba 5 flickr private photos flickrj

我正在通过 Flickr API 进行经过身份验证的调用来访问照片。但我只得到我的公开照片,而没有任何私人照片。

下面给出的是我正在使用的代码,

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());

        }

     }
Run Code Online (Sandbox Code Playgroud)

Pab*_*aba 0

我通过采用不同的方法设法解决了这个问题。

这就是我解决这个问题的方法。我没有使用 GET 方法,而是使用 photoSetsInterface (photoSetsInterface.getList(auth.getUser().getId()).getPhotosets()) 中的 getList 方法。对于此方法,您可以将 auth_token 作为输入参数传递。因此它为您提供了所有照片集。然后我拍摄了每张照片并在所有隐私级别下检索图像。

然后您可以使用 PhotosInterface 中的 getNotInSet 方法拍摄不在集合中的所有照片。getNotInSet 方法返回不在集合中的所有照片,无论隐私级别如何。

您可以在我的博客中找到示例代码。