{"errors":[{"message":"Internal error","code":131}]}


#1
var oauth = require('cloud/oauth.js');
var sha = require('cloud/sha1.js');

var urlLink = 'https://api.twitter.com/1.1/statuses/update_with_media.json';

var path = 'C:/Users/mohagarw/Desktop/test.png';
var imageEncode = fs.readFileSync(path).toString('base64');

var oauth_consumer_key = "xxxxxxxxxxxxxxxxxxxxxx";
var consumerSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

var oauth_token = "306673734-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var tokenSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";

var nonce = oauth.nonce(32);
var ts = Math.floor(new Date().getTime() / 1000);
var timestamp = ts.toString();

var accessor = {
    "consumerSecret": consumerSecret,
    "tokenSecret": tokenSecret
};


var params = {
    "oauth_consumer_key": oauth_consumer_key,
	"oauth_nonce": nonce,
	"oauth_signature_method": "HMAC-SHA1",
	"oauth_timestamp": timestamp,
	"oauth_token": oauth_token,
	"oauth_version": "1.0"
};
var message = {
    "method": "POST",
    "action": urlLink,
    "parameters": params
};


//lets create signature
oauth.SignatureMethod.sign(message, accessor);
var normPar = oauth.SignatureMethod.normalizeParameters(message.parameters);
var baseString = oauth.SignatureMethod.getBaseString(message);
var sig = oauth.getParameter(message.parameters, "oauth_signature") + "=";
var encodedSig = oauth.percentEncode(sig); //finally you got oauth signature


var boundary = "--0246824681357ACXZabcxyz";
var data     = "";


data += "--" + boundary + "\r\n"
data += 'Content-Disposition: form-data; name="status" \r\n'	
data += 'Hello \r\n';

data += "--" + boundary + "\r\n"

data += 'Content-Type: image/png; name="media" \r\n'

data += 'Content-Transfer-Encoding: base64 \r\n'

//data += 'Content-ID: <media> \r\n'

data += 'Content-Disposition: form-data; name="media"; filename="test.PNG" \r\n'

//data += 'Content-Location: media \r\n \r\n'

data += imageEncode;

data += "\r\n";

data += "--" + boundary + "--" + " \r\n";



$.ajax({
    url: urlLink,
    type: 'POST',
	data: data,
    beforeSend: function(xhr){
		xhr.setRequestHeader('Content-Type','multipart/form-data; boundary= "'+boundary+'"');
		xhr.setRequestHeader("Authorization",'OAuth oauth_consumer_key="'+oauth_consumer_key+'",oauth_signature_method="HMAC-SHA1",oauth_timestamp="' + timestamp + '",oauth_nonce="' + nonce + '",oauth_version="1.0",oauth_token="'+oauth_token+'",oauth_signature="' + encodedSig + '"');  
   },
   success: function(data) { 
		alert("Tweeted!"); 
   },
   error:function(exception){
	   alert("Exeption:"+exception);
	}
  });