How do i make a media tweet using google-apps-script?

Viewed 627

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 ?

1 Answers
Related