Last active
August 29, 2015 14:08
-
-
Save colorstain/f3b0660f540dad8a5d9d to your computer and use it in GitHub Desktop.
googleads error
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
# Import appropriate modules from the client library. | |
from googleads import dfp | |
# Set the line item ID and creative IDs to associate. | |
LINE_ITEM_ID = 'INSERT_LINE_ITEM_ID_HERE' | |
CREATIVE_IDS = ['INSERT_CREATIVE_IDS_HERE'] | |
def main(client, line_item_id, creative_ids): | |
# Initialize appropriate service. | |
lica_service = client.GetService( | |
'LineItemCreativeAssociationService', version='v201408') | |
licas = [] | |
for creative_id in creative_ids: | |
licas.append({'creativeId': creative_id, | |
'lineItemId': line_item_id, | |
'manualCreativeRotationWeight': 0.3 # add a manual rotation weight | |
}) | |
# Create the LICAs remotely. | |
licas = lica_service.createLineItemCreativeAssociations(licas) | |
# Display results. | |
if licas: | |
for lica in licas: | |
print ('LICA with line item id \'%s\', creative id \'%s\', and ' | |
'status \'%s\' was created.' % | |
(lica['lineItemId'], lica['creativeId'], lica['status'])) | |
else: | |
print 'No LICAs created.' | |
if __name__ == '__main__': | |
# Initialize client object. | |
dfp_client = dfp.DfpClient.LoadFromStorage() | |
main(dfp_client, LINE_ITEM_ID, CREATIVE_IDS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment