twitter #2
@ -20,9 +20,7 @@ def create_app():
|
|||||||
twitter_db.init_app(app)
|
twitter_db.init_app(app)
|
||||||
campaign_db.init_app(app)
|
campaign_db.init_app(app)
|
||||||
|
|
||||||
twitter_db.drop_all(app=app)
|
|
||||||
twitter_db.create_all(app=app)
|
twitter_db.create_all(app=app)
|
||||||
campaign_db.drop_all(app=app)
|
|
||||||
campaign_db.create_all(app=app)
|
campaign_db.create_all(app=app)
|
||||||
|
|
||||||
app.register_blueprint(twitter, url_prefix='/twitter')
|
app.register_blueprint(twitter, url_prefix='/twitter')
|
||||||
|
@ -68,9 +68,9 @@ def add_twitter_account():
|
|||||||
dot_index = trimmed_text.rfind(".")
|
dot_index = trimmed_text.rfind(".")
|
||||||
space_index = trimmed_text.rfind(" ")
|
space_index = trimmed_text.rfind(" ")
|
||||||
if dot_index > 0:
|
if dot_index > 0:
|
||||||
tweet_text = trimmed_text[:dot_index].capitalize()
|
tweet_text = trimmed_text[:dot_index + 1].capitalize()
|
||||||
else:
|
else:
|
||||||
tweet_text = trimmed_text[:space_index].capitalize()
|
tweet_text = trimmed_text[:space_index + 1].capitalize()
|
||||||
|
|
||||||
# create post on twitter
|
# create post on twitter
|
||||||
oauth = OAuth1Session(
|
oauth = OAuth1Session(
|
||||||
@ -82,7 +82,7 @@ def add_twitter_account():
|
|||||||
|
|
||||||
response = oauth.post(
|
response = oauth.post(
|
||||||
"https://api.twitter.com/2/tweets",
|
"https://api.twitter.com/2/tweets",
|
||||||
json={"text": tweet_text + str(dot_index) + str(space_index)},
|
json={"text": tweet_text},
|
||||||
).json()['data']
|
).json()['data']
|
||||||
|
|
||||||
# save campaign to database
|
# save campaign to database
|
||||||
|
Loading…
Reference in New Issue
Block a user