-
Notifications
You must be signed in to change notification settings - Fork 114
v9 update for TA->CA #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
v9 update for TA->CA #278
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
87e25b2
Update audience.py
BJapac 4362055
Update test_targeted_audiences.py
BJapac 4be3b55
Update __init__.py
BJapac 2c9c716
Create custom_audience.py
BJapac 829761b
Update account.py
BJapac 57aba9f
Update campaign.py
BJapac f5eb1c5
Update custom_audience.py
BJapac 1e2924b
Create custom_audience_load.json
BJapac ecc058d
Rename custom_audience_load.json to custom_audiences_load.json
BJapac ddf9717
Rename tailored_audiences_all.json to custom_audiences_all.json
BJapac 7093114
Update and rename tailored_audiences_permissions_all.json to custom_a…
BJapac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import hashlib | ||
| from twitter_ads.client import Client | ||
| from twitter_ads.audience import CustomAudience | ||
|
|
||
| CONSUMER_KEY = 'your consumer key' | ||
| CONSUMER_SECRET = 'your consumer secret' | ||
| ACCESS_TOKEN = 'access token' | ||
| ACCESS_TOKEN_SECRET = 'access token secret' | ||
| ACCOUNT_ID = '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) | ||
|
|
||
| # create a new custom audience | ||
| audience = CustomAudience.create(account, 'test CA') | ||
|
|
||
| # sample user | ||
| # all values musth be sha256 hashed | ||
| email_hash = hashlib.sha256("test-email@test.com").hexdigest() | ||
|
|
||
| # create payload | ||
| user = [{ | ||
| "operation_type": "Update", | ||
| "params": { | ||
| "users": [{ | ||
| "email": [ | ||
| email_hash | ||
| ] | ||
| }] | ||
| } | ||
| }] | ||
|
|
||
| # update the custom audience | ||
| success_count, total_count = audience.users(user) | ||
| if success_count == total_count: | ||
| print(("Successfully added {total_count} users").format(total_count=total_count)) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "data_type": "custom_audience", | ||
| "data": { | ||
| "targetable": false, | ||
| "name": "TA #2", | ||
| "targetable_types": [ | ||
| "WEB", | ||
| "EXCLUDED_WEB" | ||
| ], | ||
| "audience_type": "WEB", | ||
| "id": "abc2", | ||
| "reasons_not_targetable": [ | ||
| "TOO_SMALL" | ||
| ], | ||
| "list_type": null, | ||
| "created_at": "2014-03-09T20:35:41Z", | ||
| "updated_at": "2014-06-11T09:38:06Z", | ||
| "partner_source": "OTHER", | ||
| "deleted": false, | ||
| "audience_size": null | ||
| }, | ||
| "request": { | ||
| "params": { | ||
| "account_id": "2iqph", | ||
| "name": "TA #2", | ||
| "list_type": "EMAIL" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BJapac can you remove the
data_typefield from the golden data? Might make sense to regenerate these given that the API response has likely changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Will do.