Updated code snippet for a Scripting News blog post, with corrected code
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
//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