简体   繁体   English

尝试使用request.js更新Twitter状态

[英]Trying to update Twitter status with request.js

This returns a "Bad Authentication Data" error 这将返回“错误验证数据”错误

  request.post({
    url: "https://api.twitter.com/1.1/statuses/update.json",
    oauth: {
      consumer_key: auth.twitter.consumerKey,
      consumer_secret: auth.twitter.consumerSecret,
      access_token_key: this.authToken,
      access_token_secret: this.authSecret
    },
    params: {
      status: "Check this out!!"
    }
  }, function(err, response, body) {
    return console.log(err, body); // null '{"errors":[{"message":"Bad Authentication data","code":215}]}'
  });

Any idea what I'm doing wrong? 知道我做错了什么吗?

There are a couple of things that are preventing this from running: 有几件事阻止了它的运行:

access_token_key should be token , and access_token_secret should be token_secret access_token_key应该是tokenaccess_token_secret应该是token_secret

Sending POST data works a bit differently with the request module. 发送POST数据与请求模块的工作方式略有不同。 Try something like this 尝试这样的事情

var r = request.post({url:url, oauth:params}, function(err, resp, body) {
    res.end("Tweet sent successfully");
});

var form = r.form();
form.append("status", "Check this out!!");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM