Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0afe951
Create pythonpublish.yml
tushdante Feb 10, 2020
ba9e7ce
Merge pull request #1 from tushdante/tushar-ci-cd
tushdante Feb 10, 2020
6382675
Update pythonpublish.yml
tushdante Feb 10, 2020
ef98d73
Update __init__.py
tushdante Feb 10, 2020
7de97b5
Update __init__.py
tushdante Feb 10, 2020
0a04af6
Merge pull request #2 from twitterdev/master
tushdante Oct 5, 2020
a78076d
Create python-package.yml
tushdante Oct 5, 2020
4e0cabd
Update python-package.yml
tushdante Oct 5, 2020
4206d23
Update python-package.yml
tushdante Oct 5, 2020
3739def
Update python-package.yml
tushdante Oct 5, 2020
8f25cec
removed windows
tushdante Oct 5, 2020
e6dda1d
removed python 3.8
tushdante Oct 5, 2020
80e1edb
Update python-package.yml
tushdante Oct 5, 2020
7488d84
remove pypy
tushdante Oct 5, 2020
2d3483b
Merge pull request #3 from tushdante/tushdante-test-ci
tushdante Oct 5, 2020
30f6eaa
Update python-package.yml
tushdante Oct 5, 2020
b8613db
Create pythonpublish.yml
tushdante Feb 10, 2020
906083b
Merge branch 'master' of github.com:tushdante/twitter-python-ads-sdk
tushdante Oct 5, 2020
863ef32
# This is a combination of 2 commits.
tushdante Feb 10, 2020
f946d60
Merge branch 'master' of github.com:tushdante/twitter-python-ads-sdk
tushdante Sep 1, 2021
beffafa
Merge https://github.com/twitterdev/twitter-python-ads-sdk
tushdante Sep 1, 2021
93d05a2
Merge branch 'master' of https://github.com/twitterdev/twitter-python…
tushdante Mar 8, 2022
c726177
Merge branch 'twitterdev-master'
tushdante Mar 8, 2022
421589e
updated cards class and examples
tushdante Mar 15, 2022
559bafe
added tests
tushdante Mar 15, 2022
d3cf0ae
fix flake8 tests
tushdante Mar 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions examples/unified_cards.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from twitter_ads.client import Client
from twitter_ads.creative import Card
from twitter_ads.http import Request


CONSUMER_KEY = 'your consumer key'
CONSUMER_SECRET = 'your consumer secret'
ACCESS_TOKEN = 'user access token'
ACCESS_TOKEN_SECRET = 'user access token secret'
ACCOUNT_ID = 'ads account id'

# initialize the client
client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

# load the advertiser account instance
account = client.accounts(ACCOUNT_ID)

# fetch all
card = Card.all(account, card_ids="1502039998987587584").first

# fetch by card-id
card = Card.load(account=account, id="1502039998987587584")

# edit card destination.url
card.components= [
{
"media_key": "13_794652834998325248",
"media_metadata": {
"13_794652834998325248": {
"type": "VIDEO",
"url": "https://video.twimg.com/amplify_video/794652834998325248/vid/640x360/pUgE2UKcfPwF_5Uh.mp4",
"width": 640,
"height": 360,
"video_duration": 7967,
"video_aspect_ratio": "16:9"
}
},
"type": "MEDIA"
},
{
"title": "Twitter",
"destination": {
"url": "http://twitter.com/newvalue",
"type": "WEBSITE"
},
"type": "DETAILS"
}
]

card.save()
print(card.components)

# create new card
newcard = Card(account=account)
newcard.name="my new card"
components= [
{
"media_key": "13_794652834998325248",
"media_metadata": {
"13_794652834998325248": {
"type": "VIDEO",
"url": "https://video.twimg.com/amplify_video/794652834998325248/vid/640x360/pUgE2UKcfPwF_5Uh.mp4",
"width": 640,
"height": 360,
"video_duration": 7967,
"video_aspect_ratio": "16:9"
}
},
"type": "MEDIA"
},
{
"title": "Twitter",
"destination": {
"url": "http://twitter.com/login",
"type": "WEBSITE"
},
"type": "DETAILS"
}
]
newcard.components=components
newcard.save()
print(newcard.id)
Loading