Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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()
@izohz

This comment has been minimized.

Copy link

izohz commented Aug 27, 2019

Sunsets don't get much better than this one over @GrandTetonNPS. #nature #sunset pic.twitter.com/YuKy2rcjyU

— US Department of the Interior (@Interior) May 5, 2014
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
@lixboop

This comment has been minimized.

Copy link

lixboop commented Sep 24, 2019

twitter for iPhone and Android?? HAH GET ON MY LEVEL LOSERS

@willacrave

This comment has been minimized.

Copy link

willacrave commented Sep 24, 2019

Nnk

@honeyomiel

This comment has been minimized.

Copy link

honeyomiel commented Sep 26, 2019

um

@ghost

This comment has been minimized.

Copy link

ghost commented Sep 28, 2019

bro how do i fill my stuff in im just tryna tweet from SouljaFridge

@azed-bit

This comment has been minimized.

Copy link

azed-bit commented Oct 3, 2019

Hello from EXO-L planet 👀

@kreasemaknae24

This comment has been minimized.

Copy link

kreasemaknae24 commented Oct 19, 2019

Yee

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented Nov 4, 2019

bro how do i fill my stuff in im just tryna tweet from SouljaFridge

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

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented Dec 26, 2019

A little guidance would be much appreciated!

bro how do i fill my stuff in im just tryna tweet from SouljaFridge

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

@Lamris-official

This comment has been minimized.

Copy link

Lamris-official commented Dec 27, 2019

Yippe

@Daddythepikin

This comment has been minimized.

Copy link

Daddythepikin commented Dec 27, 2019

You guys still tweeting with twitter for iPhone and Android beat mine

@JibootyScooty

This comment has been minimized.

Copy link

JibootyScooty commented Dec 27, 2019

I just wanna tweet from my Gucci flip flop

@Richardwaita

This comment has been minimized.

Copy link

Richardwaita commented Jan 1, 2020

I want my twitter to be IPhone

@Richardwaita

This comment has been minimized.

Copy link

Richardwaita commented Jan 1, 2020

iPhone

@dandy-coder

This comment has been minimized.

Copy link

dandy-coder commented Jan 2, 2020

How do i do this? I have python and tweepy installed

@iamkojopoku

This comment has been minimized.

Copy link

iamkojopoku commented Jan 15, 2020

Tweet from Ghetto Hustler

@DrBismuth

This comment has been minimized.

Copy link

DrBismuth commented Jan 20, 2020

You got nothing on me, i'm tweeting from Samsung Smart Coat with Google voice control.

@FuriousWiener

This comment has been minimized.

Copy link

FuriousWiener commented Jan 23, 2020

You got nothing on me I'm tweeting from Facebook

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented Jan 23, 2020

@J3ssilyn

This comment has been minimized.

Copy link

J3ssilyn commented Mar 8, 2020

HAIIII

@mrineffable

This comment has been minimized.

Copy link

mrineffable commented Apr 14, 2020

Can i insert image?

@suzybwoo

This comment has been minimized.

Copy link

suzybwoo commented Apr 27, 2020

Idk what I’m doing. I just want to do a meme.

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented Apr 27, 2020

@suzybwoo

This comment has been minimized.

Copy link

suzybwoo commented Apr 27, 2020

I want to change my Twitter source label.

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented Apr 27, 2020

I want to change my Twitter source label.

First off, make sure you have a verified email address linked to your Twitter account.
Right, you need to install Python and Tweepy. Once you have those, go to Twitter's Developer Page and Click "Create an app" then Apply for an account by:

  1. Check "Making a Bot", Next
  2. Fill out the info for country and name, Next
  3. Describe your use of the API. I put "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."
  4. YOU ARE NOT ANALYZING DATA, UNCHECK THE BOX
  5. The app will be tweeting so check the "Will your app tweet, retweet and comment?" box. I put "Tweepy and Python will be used to tweet user input from a custom source label instead of the default tag."
  6. We are not using these:
    Do you plan to display Tweets or aggregate data about Twitter content outside of Twitter?
    Will your product, service or analysis make Twitter content or derived information available to a government entity?
  7. Next, Review, Looks Good!
  8. Agree to the terms and click submit application.

Once you are approved, you can create app.

  1. Whatever you name the app will be the source tag of the tweet, so choose carefully!
  2. Use this template for ease:

App name (required):
Sack of potatoes

Application description (required)
This is my app that allows user to change device from "Twitter on x" to whatever they please

Website URL (required)
https://github.com/{YOUR NAME}

Allow this application to be used to sign in with Twitter
Enable Sign in with Twitter: No
Callback URLs: None
Terms of Service URL: None
Privacy policy URL: None
Organization name: None
Organization website URL: None

Tell us how this app will be used (required)
My application will be used to change the source device name of the tweet that it will be publishing.

  1. Now click create!
  2. Review and accept.
  3. Click the "Keys and tokens" tab
  4. Click Generate for your keys
  5. Replace the _YOUR_ACCESS_TOKEN_SECRET and others in the python code with the information on screen.
  6. Run the program and input what the tweet will say and hit enter!

Hope this helps everyone, I promised a guide so here it is!

@JoshwinAranha

This comment has been minimized.

Copy link

JoshwinAranha commented May 5, 2020

I want to change my Twitter source label.

First off, make sure you have a verified email address linked to your Twitter account.
Right, you need to install Python and Tweepy. Once you have those, go to Twitter's Developer Page and Click "Create an app" then Apply for an account by:

  1. Check "Making a Bot", Next
  2. Fill out the info for country and name, Next
  3. Describe your use of the API. I put "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."
  4. YOU ARE NOT ANALYZING DATA, UNCHECK THE BOX
  5. The app will be tweeting so check the "Will your app tweet, retweet and comment?" box. I put "Tweepy and Python will be used to tweet user input from a custom source label instead of the default tag."
  6. We are not using these:
    Do you plan to display Tweets or aggregate data about Twitter content outside of Twitter?
    Will your product, service or analysis make Twitter content or derived information available to a government entity?
  7. Next, Review, Looks Good!
  8. Agree to the terms and click submit application.

Once you are approved, you can create app.

  1. Whatever you name the app will be the source tag of the tweet, so choose carefully!
  2. Use this template for ease:

App name (required):
Sack of potatoes
Application description (required)
This is my app that allows user to change device from "Twitter on x" to whatever they please
Website URL (required)
https://github.com/{YOUR NAME}
Allow this application to be used to sign in with Twitter
Enable Sign in with Twitter: No
Callback URLs: None
Terms of Service URL: None
Privacy policy URL: None
Organization name: None
Organization website URL: None
Tell us how this app will be used (required)
My application will be used to change the source device name of the tweet that it will be publishing.

  1. Now click create!
  2. Review and accept.
  3. Click the "Keys and tokens" tab
  4. Click Generate for your keys
  5. Replace the _YOUR_ACCESS_TOKEN_SECRET and others in the python code with the information on screen.
  6. Run the program and input what the tweet will say and hit enter!

Hope this helps everyone, I promised a guide so here it is!

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

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented May 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!

@JoshwinAranha

This comment has been minimized.

Copy link

JoshwinAranha commented May 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 ?

@nachitosrobome

This comment has been minimized.

Copy link

nachitosrobome commented May 9, 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!

I've put in my keys and username but get
SyntaxError: multiple statements found while compiling a single statement

What could be the issue? It is highlighting the
import system, os, time
line.

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented May 9, 2020

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've put in my keys and username but get
SyntaxError: multiple statements found while compiling a single statement

What could be the issue? It is highlighting the
import system, os, time
line.

Could you show your code, without the API Keys obviously...

@kiimkko

This comment has been minimized.

Copy link

kiimkko commented May 10, 2020

my monkey brain dont understand

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented May 22, 2020

my monkey brain dont understand

big brain stuff

@dollgr4veyard

This comment has been minimized.

Copy link

dollgr4veyard commented May 29, 2020

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

@Baconman31

This comment has been minimized.

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

This comment has been minimized.

Copy link

nbendall34 commented Jun 15, 2020

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

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

@Baconman31

This comment has been minimized.

Copy link

Baconman31 commented Jun 15, 2020

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

This comment has been minimized.

Copy link

nbendall34 commented Jun 15, 2020

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

This comment has been minimized.

Copy link

darylowenj commented Jun 29, 2020

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

This comment has been minimized.

Copy link

bobisapotato commented Jun 30, 2020

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

@Dovaah

This comment has been minimized.

Copy link

Dovaah 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

This comment has been minimized.

Copy link

nbendall34 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?

@Dovaah

This comment has been minimized.

Copy link

Dovaah 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

This comment has been minimized.

Copy link

nbendall34 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 !

No problem Man

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented Jul 2, 2020

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

Marscop9013 commented Jul 4, 2020

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

@nbendall34

This comment has been minimized.

Copy link

nbendall34 commented Jul 7, 2020

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

This comment has been minimized.

Copy link

nbendall34 commented Jul 7, 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?

@hamzai7

This comment has been minimized.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.