Skip to content

Commit 8219871

Browse files
committed
Update example
1 parent 328dbcf commit 8219871

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

examples/promoted_tweet.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88
CONSUMER_SECRET = 'your consumer secret'
99
ACCESS_TOKEN = 'user access token'
1010
ACCESS_TOKEN_SECRET = 'user access token secret'
11-
ADS_ACCOUNT = 'ads account id'
11+
ACCOUNT_ID = 'ads account id'
1212

1313
# initialize the twitter ads api client
1414
client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
1515

1616
# load up the account instance, campaign and line item
17-
account = client.accounts(ADS_ACCOUNT)
17+
account = client.accounts(ACCOUNT_ID)
1818
campaign = account.campaigns().next()
1919
line_item = account.line_items(None, campaign_ids=campaign.id).next()
2020

2121
# create request for a simple nullcasted tweet
2222
tweet1 = Tweet.create(account, text='There can be only one...')
2323

24-
# promote the tweet using our line item
25-
promoted_tweet = PromotedTweet(account)
26-
promoted_tweet.line_item_id = line_item.id
27-
promoted_tweet.tweet_id = tweet1['id']
28-
promoted_tweet.save()
29-
3024
# create request for a nullcasted tweet with a website card
3125
website_card = WebsiteCard.all(account).next()
32-
text = "Fine. There can be two. {card_url}".format(card_url=website_card.preview_url)
33-
tweet2 = Tweet.create(account, text)
26+
tweet2 = Tweet.create(account, text='Fine. There can be two.', card_uri=website_card.card_uri)
3427

3528
# promote the tweet using our line item
36-
promoted_tweet = PromotedTweet(account)
37-
promoted_tweet.line_item_id = line_item.id
38-
promoted_tweet.tweet_id = tweet2['id']
39-
promoted_tweet.save()
29+
tweet_ids = [tweet1['id'], tweet2['id']]
30+
31+
response = PromotedTweet.attach(
32+
account,
33+
line_item_id=line_item.id,
34+
tweet_ids=tweet_ids
35+
)
36+
37+
for i in response:
38+
print(i.id)
39+
print(i.tweet_id)

0 commit comments

Comments
 (0)