Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to post media to Twitter via sendTweet #26

Open
Bolmstead opened this issue Dec 21, 2024 · 7 comments
Open

Unable to post media to Twitter via sendTweet #26

Bolmstead opened this issue Dec 21, 2024 · 7 comments

Comments

@Bolmstead
Copy link

My code:

                const imagePath = "./dog.png";

                const mediaType = "image/png";

                const image = fs.readFileSync(imagePath);
                console.log(
                    "🚀 ~ TwitterPostClient ~ generateNewTweet ~ image:",
                    image
                );
                const mediaData = [
                    {
                        data: image,
                        mediaType: mediaType,
                    },
                ];

                // Send tweet with media
                const result = await this.client.requestQueue.add(async () => {
                    try {
                        return await this.client.twitterClient.sendTweet(
                            cleanedContent,
                            undefined,
                            mediaData
                        );
                    } catch (error) {
                        console.error("Error sending tweet:", error);
                    }
                });

My console:

🚀 ~ TwitterPostClient ~ generateNewTweet ~ image: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 06 d2 00 00 06 ba 08 06 00 00 00 50 5b ec 0c 00 00 01 5f 69 43 43 50 49 43 43 20 50 72 6f 66 69 ... 3873609 more bytes>
Error sending tweet: Error: {"errors":[{"code":38,"message":"media parameter is missing."}]}
    at uploadMedia (file:///Users/berkleyolmstead/Repos/eliza/node_modules/agent-twitter-client/dist/node/esm/index.mjs:2211:13)

This seems to happen with videos as well. I feel like I'm following the correct steps to tweet the media, but maybe I'm missing something

@tcm390
Copy link

tcm390 commented Dec 21, 2024

Hey you need to disable near plugin:
comment out this
https://github.com/ai16z/eliza/blob/81d027327ebba82ef3ed473d0e914c90e18e362d/agent/src/index.ts#L48

also 494~498
https://github.com/ai16z/eliza/blob/81d027327ebba82ef3ed473d0e914c90e18e362d/agent/src/index.ts#L494

@tcm390
Copy link

tcm390 commented Dec 21, 2024

@Bolmstead
Copy link
Author

Thank you so much @tcm390! I can now post an image fine. Videos still don't seem to work, but I am getting a different error trying to post a video rather than the one I mentioned thankfully. Any chance you have been tried posting a .mp4 file?

Still diving into debugging it but this is what the current error logs show

 ⛔ ERRORS
   Error sending tweet: 
   {} 

@tcm390
Copy link

tcm390 commented Dec 21, 2024

Thank you so much @tcm390! I can now post an image fine. Videos still don't seem to work, but I am getting a different error trying to post a video rather than the one I mentioned thankfully. Any chance you have been tried posting a .mp4 file?

Still diving into debugging it but this is what the current error logs show

 ⛔ ERRORS
   Error sending tweet: 
   {} 

Thanks for the update. I haven’t tried mp4. I would check it

@tcm390
Copy link

tcm390 commented Dec 22, 2024

Thank you so much @tcm390! I can now post an image fine. Videos still don't seem to work, but I am getting a different error trying to post a video rather than the one I mentioned thankfully. Any chance you have been tried posting a .mp4 file?

Still diving into debugging it but this is what the current error logs show

 ⛔ ERRORS
   Error sending tweet: 
   {} 

Thank you for your patience! I just tested it, and the video post works on my end. I'm using the develop branch. To successfully post a tweet with a video, ensure you include the attachment, the file URL, and specify the contentType as "video/mp4". Let me know if you encounter any further issues!

@Bolmstead
Copy link
Author

@tcm390

It is working now! I am not sure what I was doing wrong, but posting videos is working great now. Thank you again for your help on this, I was stuck on this for a few days!

@cyber-quantum-forge
Copy link

Lets try to fix this, please approve i am sure i will be solve all the issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants