twitter #2

Merged
s434708 merged 50 commits from twitter into master 2022-06-09 19:42:33 +02:00
Showing only changes of commit 498d514708 - Show all commits

View File

@ -30,19 +30,19 @@ def get_twitter_campaigns():
def add_twitter_account(): def add_twitter_account():
content_type = request.headers.get('Content-Type') content_type = request.headers.get('Content-Type')
if (content_type == 'application/json'): if (content_type == 'application/json'):
json = request.json request_json = request.json
if not json['campaign_name'] or not json['user_input'] or not json['twitter_account_id']: if not request_json['campaign_name'] or not request_json['user_input'] or not request_json['twitter_account_id']:
return "Invalid request!", 400 return "Invalid request!", 400
else: else:
consumer_key = current_app.config["TWITTER_CONSUMER_KEY"] consumer_key = current_app.config["TWITTER_CONSUMER_KEY"]
consumer_secret = current_app.config["TWITTER_CONSUMER_SECERT"] consumer_secret = current_app.config["TWITTER_CONSUMER_SECERT"]
twitter_account = TwitterAccount.query.filter_by(twitter_account_id=json['twitter_account_id']).first() twitter_account = TwitterAccount.query.filter_by(twitter_account_id=request_json['twitter_account_id']).first()
# generate campaign content # generate campaign content
core_url = 'http://65.108.80.28:4999/generate' core_url = 'http://65.108.80.28:4999/generate'
payload = { payload = {
"data": json['user_input'], "data": request_json['user_input'],
"length": 400 "length": 400
} }
@ -66,9 +66,9 @@ def add_twitter_account():
# save campaign to database # save campaign to database
new_twitter_campaign = TwitterCampaign( new_twitter_campaign = TwitterCampaign(
campaign_name = json['campaign_name'], campaign_name = request_json['campaign_name'],
twitter_account_id = json['twitter_account_id'], twitter_account_id = request_json['twitter_account_id'],
user_input = json['user_input'], user_input = request_json['user_input'],
generated_content = generated_content, generated_content = generated_content,
twitter_post_id = response['id'] twitter_post_id = response['id']
) )