示例#1
0
  public FlickrPhoto getInfo(String photoId) {

    OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.flickr.com/services/rest/");
    request.addQuerystringParameter("method", "flickr.photos.getInfo");

    request.addQuerystringParameter("api_key", auth.getApiKey());
    request.addQuerystringParameter("user_id", auth.getUserId());
    request.addQuerystringParameter("photo_id", photoId);

    request.addQuerystringParameter("format", "json");
    request.addQuerystringParameter("nojsoncallback", "1");

    Response response = auth.get(request);

    return buildInfo(Json.createReader(new StringReader(response.getBody())));
  }
示例#2
0
  public void init(String[] args) {

    String requestKey = null;
    String requestSecret = null;
    String userId = null;
    String accessKey = null;
    String accessSecret = null;
    String cache = null;

    int i;

    for (i = 0; i < args.length; i++) {
      switch (args[i]) {
        case "-reqKey":
          if (i < args.length) requestKey = args[++i];
          break;

        case "-reqSecret":
          if (i < args.length) requestSecret = args[++i];
          break;

        case "-accessKey":
          if (i < args.length) accessKey = args[++i];
          break;

        case "-accessSecret":
          if (i < args.length) accessSecret = args[++i];
          break;

        case "-userId":
          if (i < args.length) userId = args[++i];
          break;

        case "-cache":
          if (i < args.length) cache = args[++i];
          break;
      }
    }

    // FlickrAuth flickr = context.getBean(FlickrAuth.class);

    logger.info(
        "initiating flickr connection:  requestKey "
            + requestKey
            + ", requestSecret= "
            + requestSecret
            + ", userId="
            + userId
            + ", accessKey = "
            + accessKey
            + ", accessSecret ="
            + accessSecret);

    flickrAuth.init(requestKey, requestSecret, userId, accessKey, accessSecret);

    logger.info("Creating default set of FlickrPhotos");

    photoService.setPhoto(new FlickrPhoto(FlickrPhoto.UNPROCESSED));
    photoService.setPhoto(new FlickrPhoto(FlickrPhoto.UNMATCHED));
    photoService.setPhoto(new FlickrPhoto(FlickrPhoto.INSUFFICIENT_METADATA_NO_DATE));
    photoService.setPhoto(new FlickrPhoto(FlickrPhoto.INSUFFICIENT_METADATA_NO_CAMERA));

    logger.info("retrieving MyPhotos cache");
    myPhotos.init(cache);
    logger.debug("Retrieved " + myPhotos.size());
  }