Hello,
I think there’s something wrong with my code but I can’t figure out what.
This is the part where I upload an image to get a media_id.
request.post({ formData: { media: fs.readFileSync('./images/flower.jpg') }, url: 'https://upload.twitter.com/1.1/media/upload.json', json: true, oauth: oauthOptions }, function (err, response, body) {
console.log(body)
});
The response is exactly what I expected.
{ media_id: 875811238164521000, media_id_string: '875811238164520960', size: 166837, expires_after_secs: 86400, image: { image_type: 'image/jpeg', w: 500, h: 600 } }
Then, I use this media_id_string for my next request:
request.post({ formData: { status: 'test', media_ids: '875811238164520960'}, url: 'https://api.twitter.com/1.1/statuses/update.json', json: true, oauth: oauthOptions }, function (err, response, body) {
console.log(body);
});
There is no error. My tweet appears on my timeline but without the image.
I’d like to know what I’m doing wrong.