使用node.js和twitterAPI获取最新推文列表 [英] Get the list of latest tweets using node.js and twitterAPI
本文介绍了使用node.js和twitterAPI获取最新推文列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了从twitter API 1.1获取我帐户推文的问题。因为我是node.js的新手。我使用了twitter模块,我的初始化看起来像这样
I got a problem to get the tweets from my account from the twitter API 1.1. Since I am new to node.js. I used twitter module and my intialization looks like this
twitter = require('twitter');
var twit = new twitter(params);
twit.get('http://api.twitter.com/1.1/statuses/user_timeline.json?count=2',{include_entities:false},);
但是当我记录数据时我得到了这个
But when I log the data I get this
[Error: HTTP Error 401: Unauthorized]statusCode: 401, data: '{"errors":[{"message":"Could not authenticate you","code":32}]}' }
任何帮助都将不胜感激。
Any help would be greatly appreciated.
推荐答案
错误信息非常明确,您需要对应用进行身份验证
Error message is very clear, you need to authenticate app
var util = require('util'),
twitter = require('twitter');
var twit = new twitter({
consumer_key: 'STATE YOUR NAME',
consumer_secret: 'STATE YOUR NAME',
access_token_key: 'STATE YOUR NAME',
access_token_secret: 'STATE YOUR NAME'
});
https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
https://npmjs.org/package/twitter
这篇关于使用node.js和twitterAPI获取最新推文列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文