How to change Twitter Source Label

sunilaleti

Sunil Aleti

Posted on August 13, 2020

How to change Twitter Source Label

You might have seen some people using completely different source labels.

tweet

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.

Alt Text


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

Image description

3) Click on App settings
Image description

4) Under User authentication settings, click on Setup
Image description

5) Enable OAuth 1.0a
Image description

6) Select Read and write under App permissions
Image description

7) You can enter either your Instagram or Twitter profile link
Image description

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.
Image description

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

Alt Text

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
Enter fullscreen mode Exit fullscreen mode

12) Now type the command and hit enter

pip install tweepy
Enter fullscreen mode Exit fullscreen mode

Alt Text

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.

Alt Text

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!")
Enter fullscreen mode Exit fullscreen mode

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!")
Enter fullscreen mode Exit fullscreen mode

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!")
Enter fullscreen mode Exit fullscreen mode

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

Alt Text

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.

Alt Text

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 😊

💖 💪 🙅 🚩
sunilaleti
Sunil Aleti

Posted on August 13, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ML Chapter 7: Natural Language Processing
machinelearning ML Chapter 7: Natural Language Processing

November 17, 2024

Top 10 Platforms to Practice Python
python Top 10 Platforms to Practice Python

November 11, 2024

Top 10 Programming Languages of the Future
programming Top 10 Programming Languages of the Future

November 10, 2024

QtWidgets and QtCore
tutorial QtWidgets and QtCore

November 26, 2024