Twitter状态更新api不起作用

时间:2015-05-11 08:20:29

标签: javascript node.js twitter

我正在尝试使用此示例程序发送推文并收到错误消息 我正在关注此tutorial

这是代码

var Twitter = require('twitter');

var client = new Twitter({
    consumer_key: 'CONSUMER_KEY',
    consumer_secret: 'CONSUMER_SECRET',
    access_token: 'ACCESS_TOKEN',
    access_token_secret: 'ACCESS_TOKEN_SECRET'
});

//var stat = ["First Tweet","Second Tweet","Third Tweet","Forth Tweet","Fifth Tweet"];

client.post('statuses/update', {status: 'I Love Twitter'},  function(error, tweet, response){
  if(error) throw error;
  console.log(tweet);  // Tweet body. 
  console.log(response);  // Raw response object. 
});

每当我运行此代码时,我都会收到以下错误

E:\Local server\nodejs\status_update\test.js:12
  if(error) throw error;
                  ^
[object Object]

1 个答案:

答案 0 :(得分:1)

尝试这种方式。固定我的。

client.post('statuses/update', {status: "words"}, function(error, tweet, response){
  if (!error) {
    console.log(tweet);
  }
});