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

Your account is locked. Visit https://twitter.com/account/access to unlock it. #225

Open
Matdu27FR opened this issue Oct 3, 2024 · 0 comments

Comments

@Matdu27FR
Copy link

🚨 Account Lockout After Posting a Tweet: Is it My Code or an API Issue?

📝 Problem Description

I am encountering an account lockout immediately after trying to post a tweet using the Twikit library. Below is the code that I'm executing. I would appreciate any insights on whether this is due to my code, or if there is an issue with the Twikit API or Twitter’s restrictions.

❓ My Question

  • Is my usage of the API incorrect, leading to the lockout?
  • Is there a limitation on the API side that I might be triggering?

Any help on identifying the cause would be appreciated!

⚙️ Code Example

import asyncio
from twikit.client.client import Client

async def login_with_cookies(client, username, email, password, cookies_file='cookies.json'):
    try:
        client.load_cookies(cookies_file)
    except FileNotFoundError:
        await client.login(auth_info_1=username, auth_info_2=email, password=password)
        client.save_cookies(cookies_file)

async def create_tweet(client, text):
    await client.create_tweet(text=text)

async def main():
    username = "your_username"
    email = "[email protected]"
    password = "your_password"
    cookies_file = f'cookies_{username}.json'
    
    client = Client(
        user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
    )
    
    await login_with_cookies(client, username, email, password, cookies_file)
    await create_tweet(client, "Hey, it's my first tweet!")
    await client.logout()

if __name__ == "__main__":
    asyncio.run(main())
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

1 participant