【问题标题】:Get private photos using flickrj-android使用 flickrj-android 获取私人照片
【发布时间】:2013-08-17 21:24:19
【问题描述】:

我正在使用开源库:https://code.google.com/p/flickrj-android/,并且有一个如何从 flickr 获取照片的示例。主要问题是我只得到公开照片。如何管理获取私人信息流/照片? 有人设法获得私人流吗?

【问题讨论】:

    标签: android private flickr photos flickrj


    【解决方案1】:

    对于 Flickrj-android,你会想使用这个方法:

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

    将此方法用于单张照片输入流。

        InputStream inputStream = flickr.getPhotosInterface().getImageAsStream(flickr.getPhotosInterface().getPhoto(PHOTO_ID), Size.ORIGINAL);
    

    【讨论】:

    • 谢谢,它可以工作,但是...我有一个问题:如何访问我的客户照片而不是我的?我用他的 API_KEY+SHARED_SECRET,但我只得到我的照片。 (第一次完成授权时,它会询问我的 flickr 凭据)
    【解决方案2】:

    我对 Java 和那个框架不是很熟悉,但会尽力提供帮助。 我在该框架中找到了下一个方法名称:

    public class PeopleInterface {
    public static final String METHOD_GET_PHOTOS = "flickr.people.getPhotos";
    
    
    /**
         * Returns photos from the given user's photostream. Only photos visible the
         * calling user will be returned. this method must be authenticated.
         *
         * @param userId
         * @param extras
         * @param perpage
         * @param page
         * @return
         * @throws IOException
         * @throws FlickrException
         * @throws JSONException
         */
        public PhotoList getPhotos(String userId, Set<String> extras, int perPage,
                int page)
    

    接下来我从 Flick API 文档中找到:

    flickr.people.getPhotos 从给定用户的照片流中返回照片。只有调用用户可见的照片才会被返回。 此方法必须经过身份验证;为用户返回公共照片, 使用 flickr.people.getPublicPhotos。

    因此,这意味着您必须通过“读取”权限进行身份验证才能获取您的私人 pohotos(您的帐户)。 如果您是该用户的联系人/朋友,您还可以获取某些用户的私人照片。

    【讨论】:

      猜你喜欢
      • 2011-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-30
      • 1970-01-01
      • 2014-01-14
      • 1970-01-01
      相关资源
      最近更新 更多