Search code examples
javaandroidtwittertwitter4j

Twitter4j - quote tweet with full 280 characters for user text without url on quoted tweet


I use org.twitter4j:twitter4j-core:4.0.6 for sanding tweets and com.twitter:twitter-text:2.0.10 for tweet validation.

When I create quote tweet I put the link on the original tweet into the tweet text. Like this
Wow! This is cool! https://twitter.com/edent/status/554772317738659840

And I expect all 280 characters available for my own text, but when I check tweet length after paste the quoted url it returns 23. For example tweet with text https://twitter.com/edent/status/554772317738659840 returns length = 23 and it means that only 257 (280-23) characters available for text. I check some other tweet clients on Android and they allow all 280 characters for text. How can I achieve this?

Code for update statuse: twitter.updateStatus(new StatusUpdate("My tweet + quotedUrl"))
Code for length check: TwitterTextParser.parseTweet("My tweet + quotedUrl").weightedLength


Solution

  • Answer myself.
    You dont need to add quoted tweet url in tweet body. You need to add it in attachment_url parameter, but attachment_url still doesn`t support in twitter4j (4.0.6 version) for some reason.

    You can add sources of twitter4j-core in your project and added it parameter yourself.

    More info about attachment_url parameter: https://developer.twitter.com/en/docs/tweets/tweet-updates