bot-utilities
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -6,6 +6,9 @@ 'use strict'; | ||
module.exports = { | ||
updateWithMedia: function (status, inReplyTo, imageBufferOrStream, callback) { | ||
var API_URL = 'https://api.twitter.com/1.1/statuses/update_with_media.json'; | ||
updateWithMedia: function (options, imageBufferOrStream, cb) { | ||
var API_URL = 'https://upload.twitter.com/1.1/media/upload.json'; | ||
var r = request.post(API_URL, { | ||
var self = this; | ||
// First we post to media/upload.json | ||
request.post(API_URL, { | ||
oauth: { | ||
@@ -16,15 +19,19 @@ consumer_key: this.config.consumer_key, | ||
token_secret: this.config.access_token_secret | ||
}, | ||
formData: { | ||
media: imageBufferOrStream | ||
}, | ||
json: true | ||
}, function (err, response, body) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
}, callback); | ||
var form = r.form(); | ||
options.media_ids = body.media_id_string; | ||
form.append('status', status); | ||
if (inReplyTo) { | ||
form.append('in_reply_to_status_id', inReplyTo); | ||
} | ||
return form.append('media[]', imageBufferOrStream); | ||
// Then we post to statuses/update.json with the media_id from | ||
// media/upload.json | ||
self.post('statuses/update', options, cb); | ||
}); | ||
} | ||
}; |
{ | ||
"name": "bot-utilities", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Utilities for Twitter bots.", | ||
@@ -16,4 +16,6 @@ "main": "bot-utilities.js", | ||
"devDependencies": { | ||
"chai": "^1.9.2", | ||
"dotenv": "^0.4.0", | ||
"mocha": "^1.21.5", | ||
"chai": "^1.9.2" | ||
"twit": "^1.1.18" | ||
}, | ||
@@ -20,0 +22,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
12158
13
131
4
5