# Set your Facebook access token
access_token = 'your_access_token_here'
# Create a Facebook Graph API object
graph = facebook.GraphAPI(access_token)
# Define ad creative details
ad_creative = {
'name': 'Professional Content Writing Services',
'body': 'Elevate your brand with engaging and high-quality content!',
'image_url': 'https://example.com/your_ad_image.jpg', # Replace with your ad image URL
'link': 'https://yourwebsite.com/content-services', # Replace with your service URL
'call_to_action': {'type': 'LEARN_MORE', 'value': {'link': 'https://yourwebsite.com/content-services'}}
}
# Create an ad
ad_id = graph.put_object('act_', 'adcreatives', **ad_creative)['id']
# Create an ad set
ad_set_id = graph.put_object('act_', 'adsets', name='Content Writing Ad Set')['id']
# Create an ad campaign
campaign_id = graph.put_object('act_', 'campaigns', name='Content Writing Campaign')['id']
# Link the ad creative, ad set, and campaign
graph.put_object(ad_id, 'adsets', adset_id=ad_set_id)
graph.put_object(ad_set_id, 'campaigns', campaign_id=campaign_id)
print(f"Ad created successfully! Ad ID: {ad_id}")
0 Comments