Hello guys I need help !
I'm working on a Telegram bot that generates images, and I want users to be able to share these images on their Twitter accounts. I've successfully uploaded the image to Twitter and obtained the media_id, but I'm struggling to figure out how to attach this image to a tweet using Twitter Web Intents.
I've referred to the Twitter Web Intents documentation (https://dev.twitter.com/docs/intents), but I couldn't find a clear example or explanation on how to include media in the tweet using Web Intents. Could someone provide guidance or a code example on how to use Twitter Web Intents to attach an image to a tweet programmatically?
so far I send image to twtter server and got media_id , I cannot send the media_id in web intent , i can send only text not media
- Send media to twitter and get media_id
onst tweet = async () => {
const uri = "https://i.imgur.com/Zl2GLjnh.jpg";
const filename = "image.png";
download(uri, filename, async function () {
try {
const mediaId = await twitterClient.v1.uploadMedia("./image.png");
console.log(mediaId);
await twitterClient.v2.tweet({
text: "Hello world! This is an image in Ukraine!",
media: {
media_ids: [mediaId],
},
});
} catch (e) {
console.log(e);
}
});
};
tweet();
Share the image on user own twitter when they press share button
export const twitterShareKeyboard = {
reply_markup: {
inline_keyboard: [
[
{
text: "Share it on X",
url: "https://twitter.com/intent/tweet?text=This meme is generated using memeProof, unleash your creativity using https://t.me/MemeProfBot",
},
],
],
remove_keyboard: true,
},
};