Giter Site home page Giter Site logo

flickrnode's Introduction

flickrnode

A lightweight API that leverages the asynchronous nature of node.js to interface with flickr.

Usage

The API should be compatible with the actual Flickr API as documented here (http://www.flickr.com/services/api/). There are also some utility methods implemented that enable easier usage of the responses and for helping with the authentication model.

Using Non authenticated methods

When constructing API calls that require no authentication (or no signing) then the simplest instantiation of the FlickrAPI should be used for example:

var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('sys');
var flickr= new FlickrAPI(your_api_key_here);

// Search for photos with a tag of 'badgers'
flickr.photos.search({tags:'badgers'},  function(error, results) {
    sys.puts(sys.inspect(results));
});

Error handling

As flickrnode uses the node.js idiom of accepting a final callback/handler function as the final argument of any asynchronous method, error handling is as simple as testing for the presence of the first argument when this callback is executed. If present the first argument will be an object literals consisting of a code and a message, the values of these properties are documented on flickr's API pages e.g.:

var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('sys');
var flickr= new FlickrAPI(your_api_key_here, your_shared_secret_key);

// Get hold of a 'frob' (requires the method to be signed, does not require authentication)
flickr.auth.getFrob(function(error, frob) {
    if( error ) fail(error);
    else sys.puts("FROB: "+ sys.inspect(frob)); 
});

// Simply print out the error
function fail (err) {
    sys.puts("ERR: " + err.code + " -  " + err.message);
};

Using methods that require signing

When executing methods that require signing (and for methods that require authentication) you must also provide your 'shared secret key':

var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('sys');
var flickr= new FlickrAPI(your_api_key_here, your_shared_secret_key);

// Get hold of a 'frob' (requires the method to be signed, does not require authentication)
flickr.auth.getFrob(function(error, frob) {
    sys.puts("FROB: "+ sys.inspect(frob)); 
});

Using methods that require authentication

Some methods require the API calls to have been previously authenticated, the process of authentication is non-sequential and involves the end-user, for details of how to properly implement this please see: http://www.flickr.com/services/api/auth.spec.html The relevant code snippets follow:

Getting the URL and 'frob' that can be used to get hold of an authenticated session

var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('sys');
var flickr= new FlickrAPI(your_api_key_here, your_shared_secret_key);

flickr.getLoginUrl("read", null, function(error, url, frob) {
    // Make a note of the frob and inform the user they need to visit the url passed in here. ......
});

Getting hold of an Authentication token after the user has visited (and accepted) the above url

Please note this method consumes the passed frob and should only be called once per session. var FlickrAPI= require('flickr').FlickrAPI; var sys= require('sys'); var flickr= new FlickrAPI(your_api_key_here, your_shared_secret_key);

flickr.auth.getToken(frob, function(error, res){
    // Make a note res.token as this is what you will be using everywhere else.
});

Setting the FlickrAPI up so that it is 'authenticated'

var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('sys');
var flickr= new FlickrAPI(your_api_key_here, your_shared_secret_key, authentication_token);

// This method requires authentication
flickr.blogs.getList(function(error, blogs) {
    sys.puts(sys.inspect(blogs));
});

Setting the FlickrAPI up so that it is 'authenticated' (alternative approach)

var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('sys');
var flickr= new FlickrAPI(your_api_key_here, your_shared_secret_key);
flickr.setAuthenticationToken(authentication_token);

// This method requires authentication
flickr.blogs.getList(function(error, blogs) {
    sys.puts(sys.inspect(foo));
});

flickrnode's People

Contributors

ciaranj avatar tidwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flickrnode's Issues

cannot run most_recent_photoset.js - httpClient request has no method 'close'

Hello,
I cannot run the most_recent_photoset.js script I have this error when I use my api flickr key :

TypeError: Object # has no method 'close'
at Request.executeRequest (/mnt/ws/users/eboudrant/45708/lib/request.js:132:13)
at People.findByUsername (/mnt/ws/users/eboudrant/45708/lib/people.js:6:21)
at Object. (/mnt/ws/users/eboudrant/45708/examples/most_recent_photoset.js:11:15)

Any idea, did I made a mistake ?
I used my flicker api key, the url from the request is working fine on flckr.

Thanks

npm please

It would be nice to have this hosted at NPM.

Flickrnode should be able to make many requests at once

I would like to be able to choose either a http client pool size (so all requests use http clients from this pool) OR make every request spawn a separate http client (this would let me directly control the amount of simultaneous requests). I think both options would be great - use predefined client pool for quick jobs or have a fine grained control when you need it.

Cheers,

Jacek

Enhancement: support for upload

I've been trying for several days to figure out how to upload images to flickr and get a response with the new image id for a few days, and nothing seems to work quite right. I'd love to see support for this added to flickrnode, as you already support auth.

Support pooled connections when calling off to flickr

Currently the api spawns a new connection for each api/feed request. It would probably be nicer to re-use connections where possible, however this perhaps should be the responsibility of the underlying APIs (node.js) to implement?

Node 0.1.30 and getRequestPromise

I'm in the process of making flickr-spy work with current node.js:

ncr:~$ node -v
v0.1.30-23-g2b91f8d

TypeError: Object #<a Request> has no method 'getRequestPromise'
    at Urls.lookupUser (/Users/ncr/dev/flickr_spy/vendor/flickr/lib/urls.js:6:26)

update for current node?

node has progressed a decent amount since flickrnode was written, and the http module has seen an API overhaul, so your library no longer works, despite being the only decent library on all of npmjs. You probably haven't looked at this in ages, but if you do... is it possible to have it updated to use the new http/request calls?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.