-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update audience.py * Update test_targeted_audiences.py * Update __init__.py * Create custom_audience.py * Update account.py * Update campaign.py * Update custom_audience.py * Create custom_audience_load.json * Rename custom_audience_load.json to custom_audiences_load.json * Rename tailored_audiences_all.json to custom_audiences_all.json * Update and rename tailored_audiences_permissions_all.json to custom_audiences_permissions_all.json
- Loading branch information
Showing
9 changed files
with
146 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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("[email protected]").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 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 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 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 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 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.