私はオープン ソース ライブラリを使用しています: https://code.google.com/p/flickrj-android/と flickr から写真を取得する方法の例があります。主な問題は、公開された写真しか取得できないことです。プライベート ストリーム/写真の取得を管理するにはどうすればよいですか? プライベート ストリームを取得できた人はいますか?
2 に答える
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);
于 2013-08-16T15:12:01.410 に答える
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)
次に見つけたFlick APIドキュメントから:
flickr.people.getPhotos 指定されたユーザーのフォトストリームから写真を返します。呼び出し元のユーザーに表示される写真のみが返されます。このメソッドは認証される必要があります。ユーザーの公開写真を返すには、flickr.people.getPublicPhotos を使用します。
したがって、プライベート pohotos (アカウント) を取得するには、「読み取り」権限で認証される必要があることを意味します。あなたがそのユーザーの連絡先/友人である場合にのみ、一部のユーザーのプライベート写真を取得することもできます.
于 2013-08-16T13:50:00.987 に答える