我有一个名为 postGirl 的函数,可以将动漫女孩的图像发布到我的 Twitter 帐户上。所有图像都下载得很好,所以我有一个生成 400 张图像的文件夹,名为 girls1.jpg - Girl400.jpg,所以这似乎不是问题。
let postGirl = (girl, girlNum) => {
let numOfGirl = girlNum + 1;
let girlImage = './img/girl' + numOfGirl + '.jpg';
var girlImageFinal = girl[3];
console.log(girlImage);
let author = girl[0];
let tags = girl[1];
let hashtags = girl[2];
console.log('posting?');
var b64content = fs.readFileSync(girlImage, { encoding: 'base64' })
OtakuBot.post('media/upload', { media_data: b64content }, function (err, data, response) {
var mediaIdStr = data.media_id_string
var altText = 'Cute Girl'
var meta_params = { media_id: mediaIdStr, alt_text: { text: altText } }
console.log('inside media/upload');
OtakuBot.post('media/metadata/create', meta_params, function (err, data, response) {
if (!err) {
let postMessage = '';
console.log(tags[0]);
postMessage = 'Cute picture with ' + tags[0] + ' and ' + tags[1] + ' by ' + author + ' #animegirls #' + author + ' #' + hashtags[0] + ' #' + hashtags[1] + ' #' + hashtags[2];
var params = { status: postMessage, media_ids: [mediaIdStr] }
OtakuBot.post('statuses/update', params, function (err, data, response) {
console.log(data)
})
} else {
console.log(err);
}
})
})
}
www说
相关分类