Skip to content

Commit a2d880d

Browse files
author
Jessica Garson
authored
Update create_tweet.py
1 parent 44ad734 commit a2d880d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Manage-Tweets/create_tweet.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
consumer_key = os.environ.get("CONSUMER_KEY")
1010
consumer_secret = os.environ.get("CONSUMER_SECRET")
1111

12-
13-
# Be sure to replace tweet-id-to-delete with the id of the Tweet you wish to delete. The authenticated user must own the list in order to delete
14-
15-
id = "tweet-id-to-delete"
16-
12+
# Be sure to add replace the text of the with the text you wish to Tweet. You can also add parameters to post polls, quote Tweets, Tweet with reply settings, and Tweet to Super Followers in addition to other features.
13+
payload = {"text": "Hello world!"}
1714

1815
# Get request token
1916
request_token_url = "https://api.twitter.com/oauth/request_token"
@@ -59,9 +56,12 @@
5956
)
6057

6158
# Making the request
62-
response = oauth.delete("https://api.twitter.com/2/tweets/{}".format(id))
59+
response = oauth.post(
60+
"https://api.twitter.com/2/tweets",
61+
json=payload,
62+
)
6363

64-
if response.status_code != 200:
64+
if response.status_code != 201:
6565
raise Exception(
6666
"Request returned an error: {} {}".format(response.status_code, response.text)
6767
)
@@ -70,4 +70,4 @@
7070

7171
# Saving the response as JSON
7272
json_response = response.json()
73-
print(json_response)
73+
print(json.dumps(json_response, indent=4, sort_keys=True))

0 commit comments

Comments
 (0)