我如何使用 google-apps-script 制作媒体推文?
How do i make a media tweet using google-apps-script?
我正在使用:
https://script.google.com/d/MKvHYYdYA4G5JJHj7hxIcoh8V4oX7X1M_/edit?usp=drive_web
作为我的 Twitter 库。我正在尝试通过从 https://unsplash.it/200/300/?random 抓取图像来发送媒体推文,我收到的媒体上传响应如下:
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}}
我的脚本如下所示:
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 制作媒体推文?
我维护您正在使用的 Twitter 库。 Twitter 要求在发布推文时媒体 ID 与 media_ids
属性(以逗号分隔的列表)一起发送。这是我为 @swagspiration 机器人发送推文时的样子:
twit.sendTweet(
tweet.text.replace(/@/g, "."), //remove @-mentions. Bad juju to @mention with bots.
{ media_ids: mediaobj.media_id_string }
);
希望对您有所帮助。
我正在使用:
https://script.google.com/d/MKvHYYdYA4G5JJHj7hxIcoh8V4oX7X1M_/edit?usp=drive_web
作为我的 Twitter 库。我正在尝试通过从 https://unsplash.it/200/300/?random 抓取图像来发送媒体推文,我收到的媒体上传响应如下:
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}}
我的脚本如下所示:
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 制作媒体推文?
我维护您正在使用的 Twitter 库。 Twitter 要求在发布推文时媒体 ID 与 media_ids
属性(以逗号分隔的列表)一起发送。这是我为 @swagspiration 机器人发送推文时的样子:
twit.sendTweet(
tweet.text.replace(/@/g, "."), //remove @-mentions. Bad juju to @mention with bots.
{ media_ids: mediaobj.media_id_string }
);
希望对您有所帮助。