【问题标题】:How do i make a media tweet using google-apps-script?如何使用 google-apps-script 制作媒体推文?
【发布时间】:2016-07-03 06:26:25
【问题描述】:

我正在使用:

https://script.google.com/d/MKvHYYdYA4G5JJHj7hxIcoh8V4oX7X1M_/edit?usp=drive_web

作为我的推特库。我正在尝试通过从https://unsplash.it/200/300/?random 抓取图像来发送媒体推文,我得到的媒体上传响应如下:

上传媒体成功。响应是 {"media_id":710312931842371584,"media_id_string":"710312931842371584","size":10318,"expires_after_secs":86400,"image":{"image_type":"image/jpeg","w":200, "h":300}}

我的脚本是这样的:

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);
    } 

}

现在我如何使用传入的 media_id_string 来制作媒体推文?

【问题讨论】:

    标签: api twitter google-apps-script twitter-oauth


    【解决方案1】:

    我维护您正在使用的 Twitter 库。 Twitter 要求在发布推文时使用media_ids 属性(在逗号分隔的列表中)发送媒体 ID。以下是我为 @swagspiration 机器人发送推文时的样子:

    twit.sendTweet(
      tweet.text.replace(/@/g, "."), //remove @-mentions.  Bad juju to @mention with bots.
      { media_ids: mediaobj.media_id_string }
    );
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-03
      • 2022-11-21
      • 1970-01-01
      相关资源
      最近更新 更多