我是 Node.js 的新手,我正在尝试让 Flickr API 在我的本地机器上运行: https ://github.com/ciaranj/flickrnode 我已经使用 npm install flickr 安装了 flickr 模块。
最简单的调用是:
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));
});
我已将“sys”更改为“util”,因为节点提示我并添加了我的 api 密钥,所以我打电话:
var FlickrAPI= require('flickr').FlickrAPI;
var sys= require('util');
var flickr= new FlickrAPI('...');
// Search for photos with a tag of 'badgers'
flickr.photos.search({tags:'badgers'}, function(error, results) {
sys.puts(sys.inspect(results));
});
运行 node myfile.js,我得到:
var flickr= new FlickrAPI('a513719086ba8c3a28d2c7726939b58e');
^
TypeError: undefined is not a function
at Object.<anonymous> (/home/charm/ciaranj-flickrnode-8a9d85f/lib/simple.js:3:13)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
有谁知道我如何克服这个问题?
谢谢!