#     'link': adcreative['object_story_spec']['video_data']['call_to_action']['value']['link'],
            #     'message': adcreative['object_story_spec']['video_data']['message'],
            #     "call_to_action": {
            #         "type": adcreative['object_story_spec']['video_data']['call_to_action']['type'],
            #         "value": {
            #             "link": adcreative['object_story_spec']['video_data']['call_to_action']['value']['link']
            #         }
            #     }
            # },
            "video_data":{
                'link_description': 'to work',
                'image_url': video.get_thumbnails(fields=[], params={})[0]['uri'],
                "video_id": vid,
                "call_to_action": {
                    "type": adcreative['object_story_spec']['video_data']['call_to_action']['type'],
                    "value": {
                        "link": adcreative['object_story_spec']['video_data']['call_to_action']['value']['link']
                    }
                }
            }
        }
    }
    new_adc = fbact.create_ad_creative(params=params)

    # using a new creative to update the ad
    ad.api_update(params={
        Ad.Field.creative: {'creative_id': new_adc[AdCreative.Field.id]}
    })

    # and it works
print("Finish!")
Example #2
0
image[AdImage.Field.filename] = 'sample.gif'
image.remote_create()

image_hash = image[AdImage.Field.hash]
# print(image)

fields = []
params = {
    'name': 'Like My Page',
    'object_story_spec': {
        'page_id': page_id,
        'link_data': {
            'image_hash': image_hash,
            'link':
            'https://scontent-icn1-1.xx.fbcdn.net/v/t1.0-1/p32x32/13010641_580724558761933_1572200345389822918_n.jpg?_nc_cat=108&_nc_ht=scontent-icn1-1.xx&oh=05a6349127fbb53ecf18aa72292a06e5&oe=5D570D6C',
            'message': 'ENTER AD MESSAGE HERE'
        }
    },
}
adcreative = my_account.create_ad_creative(fields=fields, params=params)
print(adcreative)

# fields = [
# ]
# params = {
#   'name': 'ENTER AD NAME HERE',
#   'adset_id': adset['id'],
#   'creative': {'creative_id': adcreative['creative_id']},
#   'status': 'ACTIVE'
# }
# print(AdAccount(ad_account_id).create_ad(fields=fields, params=params))