首页 > 解决方案 > 如何使用包 twi 发送图像 vie url

问题描述

我想发送带有图像的推文,但图像来自 url。我不知道该怎么做,但我认为这与仅在您的 PC 上拥有图像文件并没有太大不同,因为实际的 url 以 .jpg/.png 结尾。

module.exports = (message, imageURL) => {
    T.post("media/upload", { media: imageURL }, function (error, media, response) {
        if (error) {
            console.log(error)
        } else {
            const status = {
                status: message,
                media_ids: media.media_id_string
            }
                T.post("statuses/update", status, function (error, tweet, response) {
                    if (error) {
                        console.log(error)
                    } else {
                        console.log("Successfully tweeted an image!")
                    }
                })
        }
    })
};

我是整个 twit 包的新手,所以我确定我只是忽略了它,但任何帮助将不胜感激。

标签: node.jsnpm

解决方案


推荐阅读