-
Notifications
You must be signed in to change notification settings - Fork 8
Sandbox Ad Account Testing Environment
Facebook ads application(Facebook app with Marketing api) allows to create an use ad sandbox account through which the whole create ad hierarchy can be created.
- go to
Facebook App -> Marketing Api -> Tools
- create a sandbox.
- associate a Facebook Page with it(if you dont have one create a dummy facebook page under your account)
- go to
Facebook App -> Roles -> Test Users
- find Sandbox Ad Account in Test Users
- clink on
Edit -> Get Access Token For This Test User
You can alternatively set password and log in to the facebook however using facebook ad manager is restricted.
for details see this: https://developers.facebook.com/docs/marketing-api/buying-api Follow these steps:
GET to https://graph.facebook.com/v3.0/me/adaccounts?access_token=<token>
should return object with id like act_1234567890
POST to
https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/campaigns?access_token=<token>
&name=L3 With Lifetime Budget&objective=LINK_CLICKS&status=PAUSED
POST to
https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/adsets?access_token=<token>
body form-data params:
name:my ad set fb target
billing_event:IMPRESSIONS
bid_amount:100
daily_budget:1000
campaign_id: CAMPAIGN_ID
targeting:{"geo_locations":{"countries":["US"]},"publisher_platforms":["facebook"]}
start_time:2018-05-20T04:45:17+0000
end_time:2018-05-28T04:45:17+0000
optimization_goal:REACH
curl \
-F 'filename=@path_to_some_picture' \
-F 'access_token=<token>' \
https://graph.facebook.com/v2.11/<AD_ACCOUNT_ID>/adimages
retrieve url and hash to the picture via call to GET https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/adimages?access_token=<token>&fields=url,hash
POST to https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/adcreatives?access_token=<token>
body form-data
name:blabla creative
object_story_spec:{ "link_data": { "image_hash": "<IMAGE_HASH>", "link": "<IMAGE_URL>", "message": "try it out" }, "page_id": "<ASSOCIATED_FACEBOOK_PAGE_ID>"}
POST to
https://graph.facebook.com/v3.0/<AD_ACCOUNT_ID>/ads?access_token=<TOKEN>
&name=my ad 4&status=ACTIVE&creative={"creative_id":"<AD_CREATIVE_ID>"}&adset_id=<ADSET_ID>
repeat this to fill ad accounts with more data..