Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A bit of server code, referenced in a blog post on Scripting News
//see this blog post for background -- http://scripting.com/2014/07/01/twitterApiUpdatewithmedia.html
var buffer = new Buffer (body, "base64");
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 (response);
}
}
var r = request.post (params, requestCallback);
var form = r.form ();
form.append ("status", parsedUrl.status);
form.append ("media[]", buffer); //I believe this is where the problem lies! DW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment