当前位置: 首页>>代码示例>>Java>>正文


Java Flickr类代码示例

本文整理汇总了Java中com.flickr4java.flickr.Flickr的典型用法代码示例。如果您正苦于以下问题:Java Flickr类的具体用法?Java Flickr怎么用?Java Flickr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Flickr类属于com.flickr4java.flickr包,在下文中一共展示了Flickr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authorize

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
public static Auth authorize(Flickr flickr, File authDirectory, String username) throws IOException, SAXException, FlickrException {
	AuthStore authStore = new FileAuthStore(authDirectory);
	Auth auth = authStore.retrieve(flickr.getPeopleInterface().findByUsername(username).getId());
	if (auth != null) {
		RequestContext.getRequestContext().setAuth(auth);
		return auth;
	}

	AuthInterface authInterface = flickr.getAuthInterface();
	Token accessToken = authInterface.getRequestToken();

	String url = authInterface.getAuthorizationUrl(accessToken, Permission.READ);
	System.out.println("Please visit the following URL to get your authorization token:");
	System.out.println();
	System.out.println(url);
	System.out.println();
	System.out.print("Enter your token: ");
	String tokenKey = new Scanner(System.in).nextLine();

	Token requestToken = authInterface.getAccessToken(accessToken, new Verifier(tokenKey));

	auth = authInterface.checkToken(requestToken);
	RequestContext.getRequestContext().setAuth(auth);
	authStore.store(auth);
	return auth;
}
 
开发者ID:masneyb,项目名称:flickrdownload,代码行数:27,代码来源:Authentication.java

示例2: afterPropertiesSet

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    flickr = new Flickr(apiKey, sharedSecret, new REST());

    final AuthInterface authInterface = flickr.getAuthInterface();
    Token requestToken = new Token(token, tokenSecret);
    Auth auth = authInterface.checkToken(requestToken);
    flickr.setAuth(auth);

    auth.getUser().setFamily(true);

    RequestContext requestContext = RequestContext.getRequestContext();
    requestContext.setAuth(auth);

    Flickr.debugRequest = false;
    Flickr.debugStream = false;

    final User user = auth.getUser();
    userId = user.getId();
}
 
开发者ID:sapka12,项目名称:mosaicmaker,代码行数:21,代码来源:FlickrFactory.java

示例3: PhotoDiscoveryHandler

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
@VisibleForTesting
public PhotoDiscoveryHandler(final Type photoHandler, final Type discoveryHandler, final File baseDir, final Flickr flickr) throws IOException {
  this.baseDir = baseDir;
  if (Void.TYPE.equals(photoHandler)) {
    this.photoHandler = new PhotoHandler(flickr, 2);
  } else {
    this.photoHandler = (PhotoHandler) photoHandler;
  }
  if (Void.TYPE.equals(discoveryHandler)) {
    this.discoveryHandler = new DiscoveryHandler();
  } else {
    this.discoveryHandler = (DiscoveryHandler) discoveryHandler;
  }
  this.config = null;
  this.executor = null;
  this.listener = null;
}
 
开发者ID:edersonmf,项目名称:flickring,代码行数:18,代码来源:PhotoDiscoveryHandler.java

示例4: createSetlevelXml

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
public Element createSetlevelXml(Flickr flickr) throws IOException, SAXException, FlickrException {
	Logger.getLogger(getClass()).info(String.format("Downloading information for set %s - %s",
			getSetId(), getSetTitle()));

	Element setXml = new Element("set")
			.addContent(XmlUtils.createApplicationXml())
			.addContent(XmlUtils.createUserXml(this.configuration))
			.addContent(new Element("id").setText(getSetId()))
			.addContent(new Element("title").setText(getSetTitle()))
			.addContent(new Element("description").setText(getSetDescription()));

	download(flickr, setXml);

	IOUtils.findFilesThatDoNotBelong(getSetDirectory(), this.expectedFiles, this.configuration.addExtensionToUnknownFiles);
	return setXml;
}
 
开发者ID:masneyb,项目名称:flickrdownload,代码行数:17,代码来源:AbstractSet.java

示例5: getOriginalVideoUrl

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
private static String getOriginalVideoUrl(Flickr flickr, String photoId) throws IOException, FlickrException, SAXException {
	String origUrl = null;
	String hdUrl = null;
	String siteUrl = null;
	for (Size size : (Collection<Size>) flickr.getPhotosInterface().getSizes(photoId, true)) {
		if (size.getSource().contains("/play/orig"))
			origUrl = size.getSource();
		else if (size.getSource().contains("/play/hd"))
			hdUrl = size.getSource();
		else if (size.getSource().contains("/play/site"))
			siteUrl = size.getSource();
	}
	if (origUrl != null)
		return origUrl;
	else if (hdUrl != null)
		return hdUrl;
	else if (siteUrl != null)
		return siteUrl;
	else
		return null;
}
 
开发者ID:masneyb,项目名称:flickrdownload,代码行数:22,代码来源:AbstractSet.java

示例6: download

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
@Override
protected void download(Flickr flickr, Element setXml) throws IOException, SAXException, FlickrException {
	int pageNum = 1;
	int retrievedPhotos = 0;
	int totalPhotos = 0;
	do {
		PhotoList photos = flickr.getPhotosetsInterface().getPhotos(getSetId(), 500, pageNum++);

		totalPhotos = photos.getTotal();

		for (int i = 0; i < photos.size(); i++) {
			retrievedPhotos++;
			Photo photo = (Photo) photos.get(i);
               Logger.getLogger(Set.class).info("Processing photo " + retrievedPhotos + " of " + totalPhotos + ": " + photo.getUrl());
			processPhoto(photo, flickr, setXml);
		}
	} while (retrievedPhotos < totalPhotos);		
}
 
开发者ID:masneyb,项目名称:flickrdownload,代码行数:19,代码来源:Set.java

示例7: Upload

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
public Upload(File authsDir) throws FlickrException, IOException {
    Properties properties;
    InputStream in = null;
    try {
        in = Upload.class.getResourceAsStream("setup.properties");
        properties = new Properties();
        properties.load(in);
    } finally {
        IOUtilities.close(in);
    }

    flickr = new Flickr(properties.getProperty("apiKey"),
            properties.getProperty("secret"), new REST());
    this.nsid = properties.getProperty("nsid");

    if (authsDir != null) {
        this.authStore = new FileAuthStore(authsDir);
    }
}
 
开发者ID:entercritical,项目名称:SwanFlickrUploader,代码行数:20,代码来源:Upload.java

示例8: queryFlickrOnUserEmail

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
/**
 * Having what we presume is an email, query Flickr for the UserId string
 * 
 * @param presumedEmail
 * @return Flickr user's Id string if found, otherwise null
 * @throws FlickrException Flickr throws with a user not found message if
 *             such applies
 */
private String queryFlickrOnUserEmail(Flickr flickr, String presumedEmail) throws FlickrException
{
	String flickrUserId = null;
	PeopleInterface pi = flickr.getPeopleInterface();
	User flickrUser = null;
	try
	{
		flickrUser = pi.findByEmail(presumedEmail);
	}
	catch( FlickrException fe ) // NOSONAR - throw these in the raw, wrap
								// any others
	{
		throw fe;
	}
	catch( Exception e )
	{
		throw Throwables.propagate(e);
	}

	if( flickrUser != null )
	{
		flickrUserId = flickrUser.getId();
	}

	return flickrUserId;
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:FlickrServiceImpl.java

示例9: queryFlickrOnUsername

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
/**
 * Having what we presume is an email, query Flickr for the UserId string
 * 
 * @param presumedEmail
 * @return Flickr user's Id string if found, otherwise null
 * @throws FlickrException Flickr throws with a user not found message if
 *             such applies
 */
private String queryFlickrOnUsername(Flickr flickr, String presumedUsername) throws FlickrException
{
	String flickrUserId = null;
	PeopleInterface pi = flickr.getPeopleInterface();
	User flickrUser = null;
	try
	{
		flickrUser = pi.findByUsername(presumedUsername);
	}
	catch( FlickrException fe ) // NOSONAR - throw these in the raw, wrap
								// any others
	{
		throw fe;
	}
	catch( Exception e )
	{
		throw Throwables.propagate(e);
	}

	if( flickrUser != null )
	{
		flickrUserId = flickrUser.getId();
	}

	return flickrUserId;
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:FlickrServiceImpl.java

示例10: getFlickr

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
private Flickr getFlickr(String apiKey, String apiSharedSecret)
{
	Transport rest = new REST();
	if( Check.isEmpty(apiKey) )
	{
		return new Flickr(FLICKR_API_KEY, FLICKR_SHARED_SECRET, rest);
	}
	return new Flickr(apiKey, apiSharedSecret, rest);
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:FlickrServiceImpl.java

示例11: GUI

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
public GUI() throws FlickrException {
	isRunning = false;
	sizes = new ImageSizes();
	flickr = new Flickr(FlickrConfig.API_KEY, FlickrConfig.SECRET_KEY, new REST());
	flickrAuth = new FileAuthStore(Settings.getAuthDirectory());

	initComponents();
	Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
	updateComponents();
}
 
开发者ID:lutana-de,项目名称:easyflickrbackup,代码行数:12,代码来源:GUI.java

示例12: getPhotoLocation

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
public IDirectPosition getPhotoLocation(String photoId)
        throws IOException, ParserConfigurationException, SAXException {
    // make the query URL
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("method", "flickr.photos.geo.getLocation");
    parameters.put("photo_id", photoId);
    parameters.put(Flickr.API_KEY, apiKey);
    ParameterList paramList = new ParameterList();
    for (String param : parameters.keySet()) {
        paramList.add(param, parameters.get(param));
    }
    String requestUrl = transport.getScheme() + "://" + transport.getHost() + transport.getPath();
    String urlString = paramList.appendTo(requestUrl);
    URL url = new URL(urlString);

    // Connection
    URLConnection urlConn;
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
    urlConn = (URLConnection) url.openConnection(proxy);

    // Get connection inputstream
    InputStream is = urlConn.getInputStream();

    FlickRPhotoParser parser = new FlickRPhotoParser();
    FlickRLocation location = parser.parseLocation(is);

    return location.getPosition();
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:29,代码来源:FlickRLoader.java

示例13: GetFlickrPhotos

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
public GetFlickrPhotos(Double longitude, Double latitude, Flickr flickr, Integer limitPerPage, Integer nbPage, Poi featurePoi) {
    this.longitude = longitude;
    this.latitude = latitude;
    this.flickr = flickr;
    this.limitPerPage = limitPerPage;
    this.nbPage = nbPage;
    this.featurePoi = featurePoi;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:9,代码来源:GetFlickrPhotos.java

示例14: setup

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
@Override
public void setup(ImageCollectionConfig config) throws ImageCollectionSetupException {

	try {
		final String apikey = config.read("webpage.flickr.apikey");
		final String secret = config.read("webpage.flickr.secret");
		flickr = new Flickr(apikey, secret, new REST(Flickr.DEFAULT_HOST));

	} catch (final Exception e) {
		throw new ImageCollectionSetupException("Faile to setup, error creating the flickr client");
	}

	super.setup(config);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:15,代码来源:FlickrWebpageImageCollection.java

示例15: fromGallery

import com.flickr4java.flickr.Flickr; //导入依赖的package包/类
private static <IMAGE extends Image<?, IMAGE>> FlickrImageDataset<IMAGE> fromGallery(
		InputStreamObjectReader<IMAGE> reader,
		FlickrAPIToken token,
		String urlString, int number) throws Exception
{
	final Flickr flickr = makeFlickr(token);

	final Gallery gallery = flickr.getUrlsInterface().lookupGallery(urlString);

	return createFromGallery(reader, token, gallery, number);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:12,代码来源:FlickrImageDataset.java


注:本文中的com.flickr4java.flickr.Flickr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。