I am using :
https://script.google.com/d/MKvHYYdYA4G5JJHj7hxIcoh8V4oX7X1M_/edit?usp=drive_web
as my twitter library. And i am trying to send a media tweet by grabbing the image from https://unsplash.it/200/300/?random , well i am getting media upload response as below :
Upload media success. Response was {"media_id":710312931842371584,"media_id_string":"710312931842371584","size":10318,"expires_after_secs":86400,"image":{"image_type":"image/jpeg","w":200,"h":300}}
And my script looks like this:
function tweetImage()
{
var props = PropertiesService.getScriptProperties(),
twit = new Twitter.OAuth(props);
if (twit.hasAccess()) {
var image = twit.grabImage("https://unsplash.it/200/300/?random");
var incomming = twit.uploadMedia(image);
var mediaId = JSON.stringify(incomming.media_id);
twit.sendTweet(subash,{media_id_string:mediaId},null);
}
}
Now how do i use incoming media_id_string to make media tweet ?
I maintain the Twitter library that you're using. Twitter requires that media IDs be sent with the media_ids
property (in a comma-separated list) when posting a Tweet. Here's how it looks when I send a Tweet for the @swagspiration bot:
twit.sendTweet(
tweet.text.replace(/@/g, "."), //remove @-mentions. Bad juju to @mention with bots.
{ media_ids: mediaobj.media_id_string }
);
Hope this helps.