Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Updated code snippet for a Scripting News blog post, with corrected code
//Goes with this blog post -- http://scripting.com/2014/07/01/twitterApiUpdatewithmedia.html#aIJWTS
var params = {
url: "https://api.twitter.com/1.1/statuses/update_with_media.json",
oauth: {
consumer_key: process.env.twitterConsumerKey,
consumer_secret: process.env.twitterConsumerSecret,
token: parsedUrl.query.oauth_token,
token_secret: parsedUrl.query.oauth_token_secret
}
}
function requestCallback (error, response, body) {
if (error) {
errorResponse (error);
}
else {
dataResponse (body);
}
}
var r = request.post (params, requestCallback);
var form = r.form ();
var buffer = new Buffer (body, "base64");
form.append ("status", parsedUrl.query.status);
form.append ("media[]", buffer, {filename: "picture.png");
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment