编程语言
首页 > 编程语言> > Flickr 4 Java-如何查找特定区域的图片/元数据?例如维也纳

Flickr 4 Java-如何查找特定区域的图片/元数据?例如维也纳

作者:互联网

最好

目标:
接收地理数据(坐标),时间戳…. “摘自在维也纳拍摄的照片.”

我的问题:
如何在Java中执行此操作? (使用flickrapi-1.2.jar)

我已经发现了什么? :
给我500张最新图片-url …:s

public static void main(String[] args) throws FlickrException, IOException,
        SAXException {

    String apiKey = "123456789abcdefghijklmnopqrstvwuxz";

    Flickr f = new Flickr(apiKey);

    PhotosInterface photosInterface = f.getPhotosInterface();
    Collection photosCollection = null;
    photosCollection = photosInterface.getRecent(500, 0);

    int i = 0;

    Photo photo = null;
    Iterator photoIterator = photosCollection.iterator();
    while (photoIterator.hasNext()) {
        i++;
        photo = (Photo) photoIterator.next();
        System.out.println(i + " - Description: " + photo.getSmallUrl());

    }
}

选项:很好的例子或一个不错的手册是welkom,因为我不知道这个API是如何工作的…

亲切的问候

解决方法:

您需要调用flickr.photos.search API方法.

使用Flickr4Java会看起来像这样:

    String apikey;
    String secret;

    // Create a Flickr instance with your data. No need to authenticate
    Flickr flickr = new Flickr(apikey, secret, new REST());

    // Set the wanted search parameters (I'm not using real variables in the example)
    SearchParameters searchParameters = new SearchParameters();
    searchParameters.setAccuracy(accuracyLevel);
    searchParameters.setBBox(minimum_longitude, 
                                 minimum_latitude, 
                                 maximum_longitude, 
                                 maximum_latitude);

    PhotoList<Photo> list = flickr.getPhotosInterface().search(searchParameters, 0, 0);

    // Do something with the list

标签:api,flickr,java
来源: https://codeday.me/bug/20191122/2060426.html