You might have seen some people using completely different source labels.
Well, today we will see how to change the Twitter source label
First, we need to have a Twitter developer account, if you don't have.
1) Just navigate to Twitter Developer website
2) Just fill out the form with details about ‘what you want to do with their API’. This process may take like 10 minutes and you will get a verification email instantly once you submitted the form.
After getting approval from Twitter. Now we can create an app
1) Open this link and click on "create app"
2) Give your app a name, this name will be shown on your tweets as a source label. And you can't name an app which is already present.
Click on Next
4) Under User authentication settings, click on Setup
6) Select Read and write under App permissions
7) You can enter either your Instagram or Twitter profile link
8) Now click on the option called Keys and Tokens. You can see your Twitter API keys and Access Tokens by clicking on view keys button and generate button respectively.
9) Now you have access to Twitter APIs, to create a Twitter app, you need to download Python.
10) Now, open the file location of where you have installed python and navigate to "Scripts" folder
C:\Users\"YourUsername"\AppData\Local\Programs\Python\Python37\Scripts
11) Now, Open Command Prompt, and type cd, give space and paste your python file location and click enter
cd C:\Users\"YourUsername"\AppData\Local\Programs\Python\Python37\Scripts
12) Now type the command and hit enter
pip install tweepy
13) Once installed, close the command prompt. Now in the python scripts folder, right-click and click on New > text document to create a new document.
14) Now open that document and paste this code inside
import tweepy
auth = tweepy.OAuthHandler("CONSUMER KEY HERE", "CONSUMER KEY SECRET HERE")
auth.set_access_token("ACCESS TOKEN HERE", "ACCESS TOKEN SECRET HERE")
api = tweepy.API(auth)
tweet = input(" ")
api.update_status(status =(tweet))
print ("Done!")
If you want to tweet with a media file like photo or video, you can use the below code
import tweepy
auth = tweepy.OAuthHandler("CONSUMER KEY HERE", "CONSUMER KEY SECRET HERE")
auth.set_access_token("ACCESS TOKEN HERE", "ACCESS TOKEN SECRET HERE")
api = tweepy.API(auth)
tweet = input("")
image="C:/Users/facadmin1/Downloads/introdev.PNG" #Enter image location
api.update_with_media(image, tweet)
print ("Done!")
To reply to tweet with your custom source label then copy the link of the tweet that you want to reply for twitter.com/aleti_sunil/status/135677656715.. and last "1356776567154876416" is the tweet id
import tweepy
auth = tweepy.OAuthHandler("CONSUMER KEY HERE", "CONSUMER KEY SECRET HERE")
auth.set_access_token("ACCESS TOKEN HERE", "ACCESS TOKEN SECRET HERE")
api = tweepy.API(auth)
tweet = input("")
api.update_status(tweet, in_reply_to_status_id = tweetid)
print ("Done!")
Now replace the placeholders with your twitter APIs. Remember that there are 4 APIs to change – API Key, API Secret Key, Access Token, and Access Token Secret.
Once done, it should look like this
15) Now save the file and name it anything, but change the save as type to “All files” and add “.py” at the end of the file name to save it as a python file and click save.
16) Now open that .py file you just made. That’s it, you can type anything in this command line and click enter.
It will be tweeted as a new tweet.
That's it. Hola you finally did it
If you still have any queries, check out the video
Hope it's useful
A ❤️ would be Awesome 😊
Latest comments (91)
it says tweepy needs to be installed i already installed it 3 times now
I did everything it told me to do but the python script said it needs elevated access so I applied for elevated access and was rejected, what do I do
Hey, so since twitter has upgraded it's Authentication process to OAuth 2.0 do we have to do anyhtinbg different? because I tried everything and it doesn't work
Will update the blogpost soon!!
How can I fix this?
File "C:\Users\X5 Gamer Yee\AppData\Local\Programs\Python\Python310\Scripts\e_reply.py", line 6, in
api.update_status(tweet, in_reply_to_status_id = twitter.com/X5GamerYee/status/1510723282563174401)
NameError: name 'twitter' is not defined
Tweeted an image and the image address got tweeted as text with together the image
i did everything same but getting error can you please help me?
C:\Users\PCofDC\AppData\Local\Programs\Python\Python310\Scripts>python -i tweeter.py
ok done
Traceback (most recent call last):
File "C:\Users\PCofDC\AppData\Local\Programs\Python\Python310\Scripts\tweeter.py", line 6, in
api.update_status(status =(tweet))
File "C:\Users\PCofDC\AppData\Local\Programs\Python\Python310\lib\site-packages\tweepy\api.py", line 46, in wrapper
return method(*args, **kwargs)
File "C:\Users\PCofDC\AppData\Local\Programs\Python\Python310\lib\site-packages\tweepy\api.py", line 1121, in update_status
return self.request(
File "C:\Users\PCofDC\AppData\Local\Programs\Python\Python310\lib\site-packages\tweepy\api.py", line 259, in request
raise Forbidden(resp)
tweepy.errors.Forbidden: 403 Forbidden
453 - You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: developer.twitter.com/en/docs/twit...
Turns out we have to use the v2 of the API, and the instructions are different
Is python an app?
What version of python should I download?
How do u fix this error
i first do all the cd path and pip install tweepy
where i come to the commend python -i testla.py
C:\Users\cat\AppData\Local\Programs\Python\Python37-32\Scripts>python -i testla.py
and after that it just stays black screened so i just input something in the cmd where this error show up afterwards:
Traceback (most recent call last):
File "testla.py", line 6, in
api.update_status(status =(tweet))
File "C:\Users\cat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tweepy\api.py", line 46, in wrapper
return method(*args, **kwargs)
File "C:\Users\cat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tweepy\api.py", line 1128, in update_status
), status=status, **kwargs
File "C:\Users\cat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tweepy\api.py", line 257, in request
raise Unauthorized(resp)
tweepy.errors.Unauthorized: 401 Unauthorized
32 - Could not authenticate you.
So update the problem i have i tried some other things and used Authentication to connect the app to my other account, because the one i wanna use the bot is. Didn't get accepted into twitter twitter developer. So I'm trying to make it so the account i have a twitter developer for, makes the app but so i can allow any other account to use it.
How do i get the consumer key or should i write something else into the code, to tweet from another account.
Because the code itself is working if i do it the account that have access to it's own consumer key and that, but how do u authorized your app so others can use it, and where do u put that code you get from the url i have a url with the account i allowed the app on that have two numbers in it
Oauth_token & auth_verifier so i'm asking how do i use another user consumer key when u can't access twitter developer on that account?
TLTR
Posting on behalf of a user since the account i wanna use my app with that have access to twitter developer. Do i need to change the code or something? since i don't have consumer key and that for the twitter account that i wanna tweet from
Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more