Reputation: 9293
I have a requirement to update twitter status with media . I am using following Twitter API for it. https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media.
Doing this with nodejs twit library "https://github.com/ttezel/twit"
twit = new Twit({
consumer_key: TWITTER_OAUTH_KEY
, consumer_secret: TWITTER_OAUTH_SECRET
, access_token: 'access token'
, access_token_secret: 'secret'
});
wallpost = {};
wallpost.status = 'media upload1 deliverdfd\nhttp://www.animalplanet.com/';
wallpost.media = [{
"media_url": "http:\/\/pbs.twimg.com\/media\/A7EiDWcCYAAZT1D.jpg",
"media_url_https": "https:\/\/pbs.twimg.com\/media\/A7EiDWcCYAAZT1D.jpg",
"url": "http:\/\/t.co\/bAJE6Vom",
"display_url": "pic.twitter.com\/bAJE6Vom",
"expanded_url": "http:\/\/twitter.com\/BarackObama\/status\/266031293945503744\/photo\/1",
"type": "photo",
}];
My post request
twit.post( "update_with_media", wallpost, function(err, res2) {
if (err) {
return next(err);
}
console.info(res2);
// returns the post id
res.json({
status: 200,
info: "OK",
id: res2.id
});
});
Am getting an error message [{"code":195,"message":"Missing or invalid url parameter"}]}. I have googled it found some threads some of them mentioning about set content type multipar form data. But i don't know how to set content type.
I have tried
var multipart = [{
"Content-Type": "multipart/form-data"
}];
wallpost.content_type = multipart;
not working for me. Please help me to solve this issue. Thank you
Upvotes: 0
Views: 616
Reputation: 14314
From the documentation you linked to
Supported image formats are PNG, JPG and GIF, including animated GIFs of up to 3MB . This data must be either the raw image bytes or encoded as base64.
You can only upload images - not links to images. Save an image locally and add it to media
as a base64 encoded string.
You can not send links - even to Twitter images.
Upvotes: 1