Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 安装Twit时出错_Json_Node.js_Twitter Oauth - Fatal编程技术网

Json 安装Twit时出错

Json 安装Twit时出错,json,node.js,twitter-oauth,Json,Node.js,Twitter Oauth,想看看我是否能为自己制作一个机器人,而不是垃圾邮件。明显地并采取了以下步骤: 从主站点下载Node.js。 在Twitter上创建了一个应用程序等等。 尝试了很多方法,然后阅读以下博客: 现在,我在这里:我从终端安装了它,然后返回: node_modules/twit └── oauth@0.9.9 然后我把我的推特应用程序的详细信息包括在下面,得到了一页又一页的错误。我检查了ShellCheck,主要是解析错误。但由于这只是复制和粘贴,我想我一定是做错了别的事情 有什么想法吗 var Twi

想看看我是否能为自己制作一个机器人,而不是垃圾邮件。明显地并采取了以下步骤:

从主站点下载Node.js。 在Twitter上创建了一个应用程序等等。 尝试了很多方法,然后阅读以下博客: 现在,我在这里:我从终端安装了它,然后返回:

node_modules/twit
└── oauth@0.9.9
然后我把我的推特应用程序的详细信息包括在下面,得到了一页又一页的错误。我检查了ShellCheck,主要是解析错误。但由于这只是复制和粘贴,我想我一定是做错了别的事情

有什么想法吗

var Twit = require('twit')

var T = new Twit({
    consumer_key:         '...'
  , consumer_secret:      '...'
  , access_token:         '...'
  , access_token_secret:  '...'
})

//
//  tweet 'hello world!'
//
T.post('statuses/update', { status: 'hello world!' }, function(err, data, response) {
  console.log(data)
})

//
//  search twitter for all tweets containing the word 'banana' since Nov. 11, 2011
//
T.get('search/tweets', { q: 'banana since:2011-11-11', count: 100 }, function(err, data, response) {
  console.log(data)
})

//
//  get the list of user id's that follow @tolga_tezel
//
T.get('followers/ids', { screen_name: 'tolga_tezel' },  function (err, data, response) {
  console.log(data)
})

//
//  retweet a tweet with id '343360866131001345'
//
T.post('statuses/retweet/:id', { id: '343360866131001345' }, function (err, data, response) {
  console.log(data)
})

//
//  destroy a tweet with id '343360866131001345'
//
T.post('statuses/destroy/:id', { id: '343360866131001345' }, function (err, data, response) {
  console.log(data)
})

//
// get `funny` twitter users
//
T.get('users/suggestions/:slug', { slug: 'funny' }, function (err, data, response) {
  console.log(data)
})

//
// post a tweet with media
//
var b64content = fs.readFileSync('/path/to/img', { encoding: 'base64' })

// first we must post the media to Twitter
T.post('media/upload', { media: b64content }, function (err, data, response) {

  // now we can reference the media and post a tweet (media will attach to the tweet)
  var mediaIdStr = data.media_id_string
  var params = { status: 'loving life #nofilter', media_ids: [mediaIdStr] }

  T.post('statuses/update', params, function (err, data, response) {
    console.log(data)
  })
})

//
//  stream a sample of public statuses
//
var stream = T.stream('statuses/sample')

stream.on('tweet', function (tweet) {
  console.log(tweet)
})

//
//  filter the twitter public stream by the word 'mango'.
//
var stream = T.stream('statuses/filter', { track: 'mango' })

stream.on('tweet', function (tweet) {
  console.log(tweet)
})

//
// filter the public stream by the latitude/longitude bounded box of San Francisco
//
var sanFrancisco = [ '-122.75', '36.8', '-121.75', '37.8' ]

var stream = T.stream('statuses/filter', { locations: sanFrancisco })

stream.on('tweet', function (tweet) {
  console.log(tweet)
})

//
// filter the public stream by english tweets containing `#apple`
//
var stream = T.stream('statuses/filter', { track: '#apple', language: 'en' })

stream.on('tweet', function (tweet) {
  console.log(tweet)
})