Publishing a tweet fails with default publish optional parameters
See original GitHub issueHello, it’s me again.
I notice an odd behavior that I’m not sure if it comes from twitter or it’s just not handled in the library. Basically, when you share a tweet with a message and an instance of PublishTweetOptionalParameters
, if that instance has the default values, like:
var tweet = Twitter.Tweet.PublishTweet(message, new PublishTweetOptionalParameters());
The publishing of that tweet fails. I noticed this when I had the following setup: I have a couple of ads and each ad can have video or image medias. When sharing one of those ads, I first create an instance of PublishTweetOptionalParameters
(or options for short). Then I run a check if that ad has any medias, if it does, it tries to upload the first 3 medias, ordered by upload number. If all 3 attempts fail, the options remain with its default values, aka the Medias
, MediaIds
and MediaBinaries
remain empty, which causes Twitter to go nuts and the publication of the given tweet fails.
Because I do my credential validation based on the success of that twitter publish (because the credential validation endpoint has a limit of 15 requests, I can do only 15 tweet publishes for 15 minutes, which is not acceptable), it caused be some problems. It’s not a big deal, I already worked it around, I just wanted to let you know.
https://gist.github.com/Stev3nT/6ff4a807314bb35eadac72473bce0e16 Here is the code that has it worked around, if you are interested. It also fixes my previous issue with uploading videos. I just return null instead of an instance of PublishTweetOptionalParameters when there are no medias uploaded. Since PublishTweet() has a second optional parameter that by default is null, this works.
Cheers!
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
No, the default
ExceptionHandler
was more supposed to work out as a way toLogExceptions
. If you want proper exception handling I would use per request exception handling.This set of tools is old and will be improved in later versions, but I need to find time to improve this.
Hello again. This is not really a bug, just a result from my negligence. Sorry once again and keep doing the awesome work you do!