Sending Image within Direct Message Issue (Bad Media)
See original GitHub issueHello! So I am unable to send images that I’m uploading within direct messages. My code is as follows: ` auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(accessKey, accessSecret)
api = tweepy.API(auth)
response = api.media_upload(media)
media_id = response.media_id_string
api.send_direct_message(recipient_id=friendID, text=message, attachment_type="media", attachment_media_id=media_id)`
My media variable is a path to a .jpg file. This image is less than the maximum upload size (it uploads successfully). I get an ID associated with the image every time I attempt this process, but I always get the error: [{‘code’: 151, ‘message’: ‘There was an error sending your message: Bad Media, unable to process: Some(InvalidMedia).’} when attaching the media to a direct message.
Any suggestions would be greatly appreciated. This API Wrapper is great! Thanks for your efforts!
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Top 5 ways to fix Android won't send picture messages problem.
Top 5 ways to fix Android won't send picture messages problem or MMS not being sent ; Step 1 – Hold the messaging...
Read more >Instagram direct doesn't let me send photos, what can I do?
It could be some kind of bug or you're sending and uploading pics from your galleries too much.
Read more >Some women shared the messages they get on Instagram. It's ...
Instagram DMs are regularly used to send image-based sexually abusive and pornographic content, according to the report. Users choose to send ...
Read more >Share photos at their best quality | Popular Science
To make the most of your images, it's important to share them at their very best quality. Here's how to tweak these settings...
Read more >Should You Send That DM? Well … - The New York Times
Even though it's common, sending a DM remains an intimate and slightly mysterious corner of social media. Here's what to keep in mind...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m glad I could help!
On Thu, Feb 6, 2020 at 09:49 abolfazl komeazi notifications@github.com wrote:
media is the local path to a .png image on your machine or server. media_id is the id field from Twitter’s response to their image upload API.
The way I got it working was using the image upload API for Twitter. The image gets uploaded and Twitter responds with the media_id. I then used that media_id and the path my local image for the media field to finally send images via direct message.
On Thu, Feb 6, 2020 at 6:45 AM abolfazl komeazi notifications@github.com wrote: