Created
November 17, 2011 14:25
-
-
Save BenHall/1373253 to your computer and use it in GitHub Desktop.
node-oauth not happy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OAuth= require('oauth').OAuth; | |
var events = require('events'); | |
var http = require('http'); | |
var eyes = require('eyes'); | |
var _ = require('underscore'); | |
tweet = function() { | |
var oAuth= new OAuth("http://twitter.com/oauth/request_token", | |
"http://twitter.com/oauth/access_token", | |
"vknnKEthhunReqNATrhjvg", "", | |
"1.0A", null, "HMAC-SHA1"); | |
oAuth.post("http://api.twitter.com/1/statuses/update.json", "411642032-lQnQzVEumOCFXcENCRA1sTcrEjRLPaI0jxEXGW9F", | |
"", {"status":"TEST oAuth twitter from Node"}, function(error, data) { | |
if(error) console.log(require('sys').inspect(error)) | |
else console.log(data) | |
}); | |
}; | |
tweet(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OAuth= require('oauth').OAuth; | |
var events = require('events'); | |
var http = require('http'); | |
var eyes = require('eyes'); | |
var _ = require('underscore'); | |
Object.prototype.tweet = function() { | |
var oAuth= new OAuth("http://twitter.com/oauth/request_token", | |
"http://twitter.com/oauth/access_token", | |
"vknnKEthhunReqNATrhjvg", "", | |
"1.0A", null, "HMAC-SHA1"); | |
oAuth.post("http://api.twitter.com/1/statuses/update.json", "411642032-lQnQzVEumOCFXcENCRA1sTcrEjRLPaI0jxEXGW9F", | |
"", {"status":"TEST oAuth twitter from Node"}, function(error, data) { | |
if(error) console.log(require('sys').inspect(error)) | |
else console.log(data) | |
}); | |
}; | |
Object.tweet(); |
When sending like that I think the content-type is set to "application/x-www-form-urlencoded" where "application/json" is expected.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error message:
{ statusCode: 401,
data: '{"error":"Could not authenticate with OAuth.","request":"/1/statuses/update.json"}' }