Skip to content

Instantly share code, notes, and snippets.

@KonradIT
Created February 16, 2019 19:27
Show Gist options
  • Star 90 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save KonradIT/0bd7243ebe8d7b3e231603880acab7cf to your computer and use it in GitHub Desktop.
Save KonradIT/0bd7243ebe8d7b3e231603880acab7cf to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys, os, time
import tweepy
keys = dict(
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
)
user = "@YOUR_USERNAME"
auth = tweepy.OAuthHandler(keys['consumer_key'], keys['consumer_secret'])
auth.set_access_token(keys['access_token'], keys['access_token_secret'])
api = tweepy.API(auth)
def tweet():
message=input("tweet: ")
api.update_status(message)
time.sleep(1000)
if __name__ == "__main__":
while 1:
tweet()
@kiimkko
Copy link

kiimkko commented May 10, 2020

my monkey brain dont understand

@nbendall34
Copy link

my monkey brain dont understand

big brain stuff

@dollgr4veyard
Copy link

my brain is too small for this i just wanna tweet from billie joe’s foot bruh

@Baconman31
Copy link

Baconman31 commented Jun 15, 2020

[Help??] Ok so I got the command to "work" in that it will give the prompt to enter my tweet but one I enter in the tweet it gives errors:
Traceback (most recent call last):
File "C:/Users/{My Name}/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/scratch.py", line 23, in
tweet()
File "C:/Users/{My Name}/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/scratch.py", line 19, in tweet
api.update_status(message)
File "C:\Users{My Name}\Desktop\idktweet\venv\lib\site-packages\tweepy\api.py", line 186, in update_status
return bind_api(
File "C:\Users{My Name}\Desktop\idktweet\venv\lib\site-packages\tweepy\binder.py", line 250, in _call
return method.execute()
File "C:\Users{My Name}\Desktop\idktweet\venv\lib\site-packages\tweepy\binder.py", line 233, in execute
raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]

Also when I first started the code said that the imports of sys and os were invalid

@nbendall34
Copy link

tweepy.error.TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]

Have you tried creating a new project in the Twitter Developers Portal

@Baconman31
Copy link

tweepy.error.TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]

Have you tried creating a new project in the Twitter Developers Portal

Ok yeah that worked, thanks for the help!

@nbendall34
Copy link

tweepy.error.TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]

Have you tried creating a new project in the Twitter Developers Portal

Ok yeah that worked, thanks for the help!

No problem man!

@darylowenj
Copy link

tweepy.error.TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]

Have you tried creating a new project in the Twitter Developers Portal

Ok yeah that worked, thanks for the help!

No problem man!
image

help I got an error.....

@bobisapotato
Copy link

KeyError you most likely put the wrong keys in try generating new ones

@samellou
Copy link

samellou commented Jul 2, 2020

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq

First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:

consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!

Reply to this is you need any help!

Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

@nbendall34
Copy link

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

Hi all, Have you tired creating a new application in the Twitter Developers Portal?

@samellou
Copy link

samellou commented Jul 2, 2020

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

Hi all, Have you tired creating a new application in the Twitter Developers Portal?

I tried and it worked, thanks !

@nbendall34
Copy link

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?
I have the same problem i need some help
Hi all, Have you tired creating a new application in the Twitter Developers Portal?

I tried and it worked, thanks !

No problem Man

@nbendall34
Copy link

UPDATE

Hi all, I know KonradIT runs this Gist but he hasn't touched it in 17 months. Below is a Repository that I have created that explains in full how to get your bot up and running. If you have any issues, Mark them in the repo. Hope you enjoy:
https://github.com/nbendall34/TwitterDeviceHandleChanger

@hamzai7
Copy link

hamzai7 commented Jul 3, 2020

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

Hi all, Have you tired creating a new application in the Twitter Developers Portal?

Hi, I've tried creating a new app and a new project but the tweet still doesn't show any device at all. Is there anything else that I can do to fix this?

@Marscop9013
Copy link

Marscop9013 commented Jul 4, 2020

What do I type On the "how do you plan on using Twitter API"

@nbendall34
Copy link

What do I type On the "how do you plan on using Twitter API"

"I want to use the Twitter API to get a bot to tweet user input but change the source label so it doesn't show "Twitter for iPhone/Android" This will be done using Python and Tweepy for simplification."

@nbendall34
Copy link

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

Hi all, Have you tired creating a new application in the Twitter Developers Portal?

Hi, I've tried creating a new app and a new project but the tweet still doesn't show any device at all. Is there anything else that I can do to fix this?

Any runtime errors?

@hamzai7
Copy link

hamzai7 commented Jul 8, 2020

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

Hi all, Have you tired creating a new application in the Twitter Developers Portal?

Hi, I've tried creating a new app and a new project but the tweet still doesn't show any device at all. Is there anything else that I can do to fix this?

Any runtime errors?

I don't get any errors errors at all. It runs perfectly except for the tweet not showing where it was posted from.

@EmMollova
Copy link

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

Hi all, Have you tired creating a new application in the Twitter Developers Portal?

Hi, I've tried creating a new app and a new project but the tweet still doesn't show any device at all. Is there anything else that I can do to fix this?

I have the same problem (tweet not showing) and it gives me this as an error: https://imgur.com/a/9K2ZaZj
Anything I could've done wrong?

@nbendall34
Copy link

I am trying this but this is what i am getting. https://imgur.com/Xy5Bshq
First, create or download this file: Main.py
Secondly, Change the following definitions to your keys and secrets:
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
Third, Enter your username
Final, hit F5 to run!
Reply to this is you need any help!
Okay, so the script worked but the tweet on my account doesn't show any device at all. Is something wrong on my developer account side of things ?

I have the same problem i need some help

Hi all, Have you tired creating a new application in the Twitter Developers Portal?

Hi, I've tried creating a new app and a new project but the tweet still doesn't show any device at all. Is there anything else that I can do to fix this?

I have the same problem (tweet not showing) and it gives me this as an error: https://imgur.com/a/9K2ZaZj
Anything I could've done wrong?

This is a tweepy error, try reinstalling via pip

@mnynbot
Copy link

mnynbot commented Feb 2, 2021

When creating your twitter application, name the app what you want the source tag to be. NOTE: renaming your existing app will not change it in tweepy

Any solution on how to do this if I already have an existing app?

@IndraIsSad
Copy link

I have the same problem (tweet not showing) and it gives me this as an error: https://imgur.com/a/9K2ZaZj
Anything I could've done wrong?

This is a tweepy error, try reinstalling via pip

https://cozy-says.anime-girls-are-the.best/3UF0HaW8 I've tried and my application is on all permissions, what happened?

@nbendall34
Copy link

I have the same problem (tweet not showing) and it gives me this as an error: https://imgur.com/a/9K2ZaZj
Anything I could've done wrong?

This is a tweepy error, try reinstalling via pip

https://cozy-says.anime-girls-are-the.best/3UF0HaW8 I've tried and my application is on all permissions, what happened?

That link look very dodgy, is it shortened?

@nbendall34
Copy link

I have the same problem (tweet not showing) and it gives me this as an error: https://imgur.com/a/9K2ZaZj
Anything I could've done wrong?

This is a tweepy error, try reinstalling via pip

https://cozy-says.anime-girls-are-the.best/3UF0HaW8 I've tried and my application is on all permissions, what happened?

Can you pastebin/message me your code (without api keys) for me to look at?

@nbendall34
Copy link

When creating your twitter application, name the app what you want the source tag to be. NOTE: renaming your existing app will not change it in tweepy

Any solution on how to do this if I already have an existing app?

You can pull the Application Keys from an existing app

@IndraIsSad
Copy link

I have the same problem (tweet not showing) and it gives me this as an error: https://imgur.com/a/9K2ZaZj
Anything I could've done wrong?

This is a tweepy error, try reinstalling via pip

https://cozy-says.anime-girls-are-the.best/3UF0HaW8 I've tried and my application is on all permissions, what happened?

Can you pastebin/message me your code (without api keys) for me to look at?

I've managed to fix it (by creating a new app) but now there is another error - It doesn't show the "Twitter for {insert here}" text
image

@nbendall34
Copy link

nbendall34 commented Feb 10, 2021 via email

@gurchpog
Copy link

AAAAAAAAAAAAAAAAAAAAANujQAEAAAAANRMSNOGfQY9BFsG5aeD1XYQHw%2Fg%3DVoL0gLaW3KMZ7vY7nsoqIqZvlIVAEsTd6jeySj8EfOpD6n7gTr

@amelie-gif
Copy link

I want my twitter to be IPhone

me as well how do we do this simply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment