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

create_tweet() on premium+ account limits tweet length #199

Open
narodnik opened this issue Jul 23, 2024 · 4 comments
Open

create_tweet() on premium+ account limits tweet length #199

narodnik opened this issue Jul 23, 2024 · 4 comments

Comments

@narodnik
Copy link

Traceback (most recent call last):
  File "/home/xyz/src/stuff/twat/./post.py", line 35, in <module>
    message = app.create_tweet(msg, files)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xyz/.local/lib/python3.12/site-packages/tweety/utils.py", line 44, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xyz/.local/lib/python3.12/site-packages/tweety/user.py", line 581, in create_tweet
    response = self.request.create_tweet(text, files, filter_, reply_to, quote, pool, place, batch_compose)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xyz/.local/lib/python3.12/site-packages/tweety/http.py", line 406, in create_tweet
    response = self.__get_response__(**request_data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xyz/.local/lib/python3.12/site-packages/tweety/http.py", line 185, in __get_response__
    return GenericError(
           ^^^^^^^^^^^^^
  File "/home/xyz/.local/lib/python3.12/site-packages/tweety/types/n_types.py", line 72, in __init__
    self._raise_exception()
  File "/home/xyz/.local/lib/python3.12/site-packages/tweety/types/n_types.py", line 92, in _raise_exception
    raise TwitterError(
tweety.exceptions.TwitterError: [186] Authorization: Tweet needs to be a bit shorter. (186)

I'm looking at the code in tweety, and it seems to be an error from Twitter. So maybe there's an alternative method we need to call?

How do you debug this? Are you using wireshark to examine the network traffic, or how can I examine the API?

@narodnik narodnik reopened this Jul 23, 2024
@narodnik
Copy link
Author

narodnik commented Jul 23, 2024

I found this link:
https://devcommunity.x.com/t/how-to-post-280-4000-characters-via-api-v2/191156

so if tweety could do this then it would be able to do sth the normal API cannot do ;)

@narodnik narodnik reopened this Jul 23, 2024
@narodnik
Copy link
Author

narodnik commented Jul 23, 2024

Is this a good tool to intercept SSL traffic or do you recommend another workflow?

https://docs.mitmproxy.org/stable/overview-getting-started/

edit: ok I used my browser's inbuilt tools, here's what I've got for a short tweet:

{
  "variables": {
    "tweet_text": "dddd",
    "dark_request": false,
    "media": {
      "media_entities": [],
      "possibly_sensitive": false
    },
    "semantic_annotation_ids": [],
    "disallowed_reply_options": null
  },
  "features": {
    "communities_web_enable_tweet_community_results_fetch": true,
    "c9s_tweet_anatomy_moderator_badge_enabled": true,
    "tweetypie_unmention_optimization_enabled": true,
    "responsive_web_edit_tweet_api_enabled": true,
    "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true,
    "view_counts_everywhere_api_enabled": true,
    "longform_notetweets_consumption_enabled": true,
    "responsive_web_twitter_article_tweet_consumption_enabled": true,
    "tweet_awards_web_tipping_enabled": false,
    "creator_subscriptions_quote_tweet_preview_enabled": false,
    "longform_notetweets_rich_text_read_enabled": true,
    "longform_notetweets_inline_media_enabled": true,
    "articles_preview_enabled": true,
    "rweb_video_timestamps_enabled": true,
    "rweb_tipjar_consumption_enabled": true,
    "responsive_web_graphql_exclude_directive_enabled": true,
    "verified_phone_label_enabled": false,
    "freedom_of_speech_not_reach_fetch_enabled": true,
    "standardized_nudges_misinfo": true,
    "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
    "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
    "responsive_web_graphql_timeline_navigation_enabled": true,
    "responsive_web_enhance_cards_enabled": false
  },
  "queryId": "..."
}

but when I made a long tweet, instead it called CreateNoteTweet, and here's the POST data:

{
  "variables": {
    "tweet_text": "....",
    "dark_request": false,
    "media": {
      "media_entities": [],
      "possibly_sensitive": false
    },
    "semantic_annotation_ids": [],
    "disallowed_reply_options": null
  },
  "features": {
    "communities_web_enable_tweet_community_results_fetch": true,
    "c9s_tweet_anatomy_moderator_badge_enabled": true,
    "tweetypie_unmention_optimization_enabled": true,
    "responsive_web_edit_tweet_api_enabled": true,
    "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true,
    "view_counts_everywhere_api_enabled": true,
    "longform_notetweets_consumption_enabled": true,
    "responsive_web_twitter_article_tweet_consumption_enabled": true,
    "tweet_awards_web_tipping_enabled": false,
    "creator_subscriptions_quote_tweet_preview_enabled": false,
    "longform_notetweets_rich_text_read_enabled": true,
    "longform_notetweets_inline_media_enabled": true,
    "articles_preview_enabled": true,
    "rweb_video_timestamps_enabled": true,
    "rweb_tipjar_consumption_enabled": true,
    "responsive_web_graphql_exclude_directive_enabled": true,
    "verified_phone_label_enabled": false,
    "freedom_of_speech_not_reach_fetch_enabled": true,
    "standardized_nudges_misinfo": true,
    "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": true,
    "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false,
    "responsive_web_graphql_timeline_navigation_enabled": true,
    "responsive_web_enhance_cards_enabled": false
  },
  "queryId": "..."
}```

so it's basically the same API with just a different function name.

This is the URL: `https://x.com/i/api/graphql/0aWhJJmFlxkxv9TAUJPanA/CreateNoteTweet`

@mahrtayyab
Copy link
Owner

Yes Long tweet required to be sent to CreateNoteTweet , it will be added in next release

@narodnik
Copy link
Author

BTW I notice a few differences between builder.py and my output above:

    "tweet_awards_web_tipping_enabled": false,
    "creator_subscriptions_quote_tweet_preview_enabled": false,
    "verified_phone_label_enabled": false,

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

2 participants