admin管理员组文章数量:1426066
I've been trying to get tumblr.js api to work for about 3 days now on localhost and hosted. My app and keys are valid since I was able to access it with php. This is the readme.md example provided from .js with changes provided by reviewing !topicsearchin/tumblr-api/tumblr.js/tumblr-api/gz8Zv-Mhex4.
var tumblr = require('index.js');
var client = tumblr.createClient({
consumer_key: '<consumer key>',
consumer_secret: '<consumer secret>',
token: '<oauth token>',
token_secret: '<oauth token secret>'
});
// Show user's blog names
client.userInfo(function (err, data) {
data.blogs.forEach(function (blog) {
console.log(blog.name);
});
});
Using firebug, I find that require is not defined selecting require('index.js') as the issue. index.js holds:
var tumblr = require('lib/tumblr');
tumblr.request(require('request'));
module.exports = tumblr;
Upon plete failure I've search online and reviewed countless articles, blogs and posts to no avail. Where am I messing up at? I want to use the api with minimal or no work-around.
I've been trying to get tumblr.js api to work for about 3 days now on localhost and hosted. My app and keys are valid since I was able to access it with php. This is the readme.md example provided from https://github./tumblr/tumblr.js with changes provided by reviewing https://groups.google./forum/#!topicsearchin/tumblr-api/tumblr.js/tumblr-api/gz8Zv-Mhex4.
var tumblr = require('index.js');
var client = tumblr.createClient({
consumer_key: '<consumer key>',
consumer_secret: '<consumer secret>',
token: '<oauth token>',
token_secret: '<oauth token secret>'
});
// Show user's blog names
client.userInfo(function (err, data) {
data.blogs.forEach(function (blog) {
console.log(blog.name);
});
});
Using firebug, I find that require is not defined selecting require('index.js') as the issue. index.js holds:
var tumblr = require('lib/tumblr');
tumblr.request(require('request'));
module.exports = tumblr;
Upon plete failure I've search online and reviewed countless articles, blogs and posts to no avail. Where am I messing up at? I want to use the api with minimal or no work-around.
Share Improve this question asked Aug 29, 2013 at 15:02 TechnoNoobTechnoNoob 314 bronze badges2 Answers
Reset to default 5I guess this question is irrelevant now, but I'll answer anyway for anyone ing across this.
I've dealt with this issue as well, and I'm guessing you're trying to do this in the browser. The Tumblr API requires a Node.js installation, which then implements the require() function.
Tumblr.js is for node.js, not in-browser javascript. You can use Tumblr's API via AJAX, normally.
For example, using jQuery you can pull up to 12 photo posts tagged #meme:
$.getJSON('http://api.tumblr./v2/blog/YOURBLOG.tumblr./posts/photo?callback=?', {
api_key: 'YOUR_API_KEY',
tag: 'meme',
limit: 12
}).then(function (json) {
//do something
});
You can get an API key from Tumblr
本文标签: javascriptTumblrjs APIrequire() failsStack Overflow
版权声明:本文标题:javascript - Tumblr.js API -- require() fails - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745467789a2659608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论