首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用flickrj-android获取私人照片

使用flickrj-android获取私人照片
EN

Stack Overflow用户
提问于 2013-08-16 00:13:20
回答 2查看 730关注 0票数 0

我使用的是开源库:https://code.google.com/p/flickrj-android/,下面是一个如何从flickr获取照片的示例。主要的问题是我只能得到公开的照片。我如何管理获取私密流/照片?有没有人设法弄到了私人流媒体?

EN

回答 2

Stack Overflow用户

发布于 2013-08-16 23:12:01

对于Flickrj-android,您需要使用以下方法:

代码语言:javascript
复制
 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();
    }

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

代码语言:javascript
复制
    InputStream inputStream = flickr.getPhotosInterface().getImageAsStream(flickr.getPhotosInterface().getPhoto(PHOTO_ID), Size.ORIGINAL);
票数 1
EN

Stack Overflow用户

发布于 2013-08-16 21:50:01

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

代码语言:javascript
复制
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。

所以,这意味着你的必须使用‘’权限进行身份验证才能获得你的私人pohoto(你的帐户)。你还可以获得一些用户的私人照片,只有当你是该用户的联系人/朋友的情况下。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18256912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档