오픈 소스 라이브러리를 사용하고 있습니다 : https://code.google.com/p/flickrj-android/ 그리고 flickr에서 사진을 얻는 방법에 대한 예제가 있습니다. 주요 문제는 공개 사진 만 받는다는 것입니다. 비공개 스트림/사진을 관리하려면 어떻게해야합니까? 누구도 비공개 스트림을 얻을 수 있었습니까?flickrj-android를 사용하여 개인 사진 가져 오기
0
A
답변
0
저는 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)
는 톡 API 문서에서 나는 다음 발견 : 주어진 사용자의 포토 스트림에서
flickr.people.getPhotos 반환 사진. 발신자가 볼 수있는 사진 만 반환됩니다. 이 메서드는 인증되어야합니다. 사용자의 공개 사진을 반환하려면 flickr.people.getPublicPhotos를 사용하십시오.
그래서, 당신 이 개인 pohotos를 얻을 수있는 '읽기'권한 (계정)으로 인증되어야한다는 것을 의미한다. 일부 사용자의 개인 사진은 해당 사용자의 친구/친구 인 경우에만 볼 수 있습니다. Flickrj - 안드로이드와
1
이 방법을 사용할 것 :
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 inputStream = flickr.getPhotosInterface().getImageAsStream(flickr.getPhotosInterface().getPhoto(PHOTO_ID), Size.ORIGINAL);
감사합니다. 작동하지만 문제가 있습니다. 내 클라이언트 사진에 액세스하려면 어떻게해야합니까? 나는 API_KEY + SHARED_SECRET을 사용했지만 사진 만받습니다. (승인이 처음 완료되면 내 플리커 자격 증명을 묻습니다) – Lunatikul