本文整理汇总了Java中com.flickr4java.flickr.Flickr.getPhotosInterface方法的典型用法代码示例。如果您正苦于以下问题:Java Flickr.getPhotosInterface方法的具体用法?Java Flickr.getPhotosInterface怎么用?Java Flickr.getPhotosInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.flickr4java.flickr.Flickr
的用法示例。
在下文中一共展示了Flickr.getPhotosInterface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: searchImages
import com.flickr4java.flickr.Flickr; //导入方法依赖的package包/类
@Override
public List<Image> searchImages(String query) throws ImageSearchException {
Flickr flickr = new Flickr(key, secret, new REST());
PhotosInterface photosInterface = flickr.getPhotosInterface();
HashSet<String> extras = new HashSet<String>();
extras.add(Extras.URL_L);
SearchParameters searchParameters = new SearchParameters();
searchParameters.setText(query);
searchParameters.setExtras(extras);
searchParameters.setTagMode("all");
List<Image> images = new ArrayList<Image>();
try {
PhotoList photoList = photosInterface.search(searchParameters, 5, 0);
for (Photo photo : (List<Photo>) photoList) {
Image image = new Image();
image.setSource("flickr");
image.setTitle(photo.getTitle());
image.setUrl(photo.getLargeUrl());
images.add(image);
}
} catch (FlickrException e) {
throw new ImageSearchException(e.getMessage(), e.getCause());
}
return images;
}
示例2: init
import com.flickr4java.flickr.Flickr; //导入方法依赖的package包/类
@PostConstruct
public void init() {
Transport transport = new REST();
f = new Flickr(apiKey, sharedSecret, transport);
photoInterface = f.getPhotosInterface();
}
示例3: searchOnParams
import com.flickr4java.flickr.Flickr; //导入方法依赖的package包/类
/**
* the expanded class FlickrSearchParameters is queried to determine what
* fine-tuning of the search parameters is required before submitting to the
* flickr service API. If a tag search has been requested, the tags will be
* tokenised on commas if any are present, otherwise on spaces. If a value
* has been set for a flickr user string, that string is examined to see if
* it is an email, a flick user-id or (failing either) a flickr user-name.
*/
@Override
public PhotoList<Photo> searchOnParams(FlickrSearchParameters params, int pageToGet, int queryLimit,
String apiKey,
String apiSharedSecret) throws FlickrException
{
Flickr flickr = getFlickr(apiKey, apiSharedSecret);
// From the unparsed user input, see if there's either a flick userid
// already provided; otherwise get the flickr id by specialised flickr
// query
/* boolean sendingFlickrUserId = */
extractUserSearchString(flickr, params);
if( params.getSearchRawText() != null )
{
String rawText = params.getSearchRawText().trim();
if( rawText.length() > 0 )
{
if( params.isTagsNotText() )
{
if( rawText.contains(",") )
{
params.setTags(rawText.split(","));
}
else
{
params.setTags(rawText.split(" "));
}
if( params.isTagsAll() )
{
params.setTagMode(ALL);
}
else
{
params.setTagMode(ANY);
}
}
else
{
params.setText(rawText);
}
}
}
// The various extras flags (to specify level of detail retrieved)
params.setExtras(EXTRAS_SET);
PhotosInterface photosInterface = flickr.getPhotosInterface();
try
{
PhotoList<Photo> photoList = photosInterface.search(params, queryLimit, pageToGet);
return photoList;
}
catch( FlickrException fe ) // NOSONAR
{
throw fe;
}
catch( Exception e )
{
throw Throwables.propagate(e);
}
}