將call_to_action添加到link_data。 信用克里斯·西蒙斯
# use picture or image_hash
fb_dummy_image = 'https://i.ytimg.com/vi/eGKWS6_187s/maxresdefault.jpg'
image_hash = "164d943385c130d64e702664c9ab1798"
data = {
"access_token": SELLIO_AD_SERVER_TOKEN,
"name": "Sample Creative",
"object_story_spec": {
"link_data": {
"call_to_action": {"type": "LEARN_MORE", "value": {"app_destination": "MESSENGER"}},
"child_attachments": [
{
"description": "$800.99",
"image_hash": image_hash,
"link": "https://www.example.com",
"name": "A1",
"call_to_action": {
"type": "LEARN_MORE",
"value": {
"app_destination": "MESSENGER",
}
},
},
{
"description": "$400.99",
"image_hash": image_hash,
"link": "https://www.example.com",
"name": "A2",
"call_to_action": {
"type": "LEARN_MORE",
"value": {
"app_destination": "MESSENGER",
}
},
},
{
"description": "$300.99",
"picture": fb_dummy_image,
"link": "https://www.messenger.com/t/xxxxxxxxxxxx",
"name": "A3",
"call_to_action": {
"type": "LEARN_MORE",
"value": {
"app_destination": "MESSENGER",
}
}
}
],
"link": "https://www.messenger.com/t/xxxxxxxxxx",
"page_welcome_message": '{"user_edit": true, "message": {"attachment": {"type": "template", "payload": {"template_type": "generic", "elements": [{"buttons": [{"url": "http://www.example.com/", "type": "web_url", "title": "View Website"}, {"type": "postback", "payload": "USER_DEFINED_PAYLOAD", "title": "Start Chatting"}], "subtitle": "Optional: Enter a subtitle to provide more information", "image_url": "https://image.ibb.co/bz5t6Q/placeholder.png", "title": "Enter a title to accompany your image"}, {"buttons": [{"url": "http://www.example.com/", "type": "web_url", "title": "View Website"}, {"type": "postback", "payload": "USER_DEFINED_PAYLOAD", "title": "Start Chatting"}], "subtitle": "2nd product", "image_url": "https://image.ibb.co/bz5t6Q/placeholder.png", "title": "a2"}, {"buttons": [{"url": "http://www.example.com/", "type": "web_url", "title": "View Website"}, {"type": "postback", "payload": "USER_DEFINED_PAYLOAD", "title": "Start Chatting"}], "subtitle": "3rd product", "image_url": "https://image.ibb.co/bz5t6Q/placeholder.png", "title": "a3"}]}}}}'
},
"page_id": "xxxxxxxxxxx"
}
}
然後也使與留言爲目標
def create_campaign(ad_account_id, campaign_name):
my_account = AdAccount(ad_account_id)
campaign = Campaign(parent_id=my_account.get_id_assured())
campaign.update({
Campaign.Field.name: campaign_name,
Campaign.Field.objective: 'MESSAGES'
})
campaign.remote_create(params={
'status': Campaign.Status.paused,
})
logging.debug(campaign)
return campaign.get_id()
廣告活動