How to change Twitter Source Label
Tags: tutorial, python
Published: 2020-08-13 22:32:55

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

![tweet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8t7ylxtu2yq46s8mvnr.png)

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.

<b>1) </b>Just navigate to [Twitter Developer website](https://developer.twitter.com/en)

<b>2) </b>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](https://dev-to-uploads.s3.amazonaws.com/i/sj0h0s810wga0ov1439q.PNG)
<hr>

After getting approval from Twitter. Now we can create an app


<b>1) </b>Open this [link](https://developer.twitter.com/en/portal/projects-and-apps) and click on "create app"

<b>2) </b>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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2glcpr824sbs7em0de9.png)

<b>3)</b> Click on **App settings**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u95j1kg3ain99ke2ua5w.png)

<b>4)</b> Under **User authentication settings**, click on **Setup**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iqomxtqz3mw32lwv5t03.png)

<b>5)</b> Enable **OAuth 1.0a**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j94lb3sx69utmmkhl90x.png)

<b>6)</b> Select **Read and write** under App permissions
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/unze733el8m6rnpe8gy5.png)

<b>7)</b> You can enter either your **Instagram** or **Twitter** profile link
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/himjo6veqksuo2vt05c6.png)

<b>8)</b> 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/irtqcx35cub5h340332t.png)

<b>9) </b>Now you have access to Twitter APIs, to create a Twitter app, you need to download Python.

<b>10) </b>Now, open the file location of where you have installed python and navigate to "Scripts" folder
<code>C:\Users\"YourUsername"\AppData\Local\Programs\Python\Python37\Scripts
</code>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/h9ur1cxdxaezsnwc3yfs.PNG)

<b>11) </b>Now, Open Command Prompt, and type cd, give space and paste your python file location and click enter
```python
cd C:\Users\"YourUsername"\AppData\Local\Programs\Python\Python37\Scripts
```

<b>12) </b>Now type the command and hit enter
```python
pip install tweepy
``` 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/80pn6q4ji6ph38uzbnl6.PNG)

<b>13) </b>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](https://dev-to-uploads.s3.amazonaws.com/i/jmowrs5m4nhv6sm2weee.png)

<b>14) </b>Now open that document and paste this code inside
```python
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
```python
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
```python
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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mq0yjjbyb27pon32ufi8.jpg)

<b>15) </b>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.

<b>16) </b>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](https://dev-to-uploads.s3.amazonaws.com/i/uww6hmqxdvqqjarn717y.PNG)

That's it. Hola you finally did it

If you still have any queries, check out the video

{% youtube otwEZXrC8O0 %}<br>

<a href="https://www.buymeacoffee.com/sunilaleti" target="_blank"><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1g0v3nxthxjw79prdacu.png"></a>


Hope it's useful

A ❤️ would be Awesome 😊