-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: as title Reviewed By: mingcaozhang Differential Revision: D43169515 fbshipit-source-id: f7c1a4ad514828c8927b31d0c73e9859f51cbffc
- Loading branch information
1 parent
3dee8f7
commit c83e8b4
Showing
3 changed files
with
7 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
CHANGELOG.md import com.webapp.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays; public class SAMPLE_CODE { public static void main (String args[]) throws APIException { String access_token = "EAAGURG71sMIBACZCyZA6dBZC5pVrUZBDI0eUaBP0iO2ZBU1zIWtTZBQBzYGK083DbHE5ZC1NK2UZBfkL6uQHbnYvP5pdaZBTiW7O2wEFn2EZA2ZB5E3ibiQ7KhuCuO7chwalbQiXOZB2VqeZBCvjZC9Js3TG1flaEYKofPPcayEIkgqZCrNCfT9tGcJR6g3De2EEdS9Lz4ZD"; String ad_account_id = "578967340074724"; String app_secret = "6a28224f006a5611bce6ee718a18f2f4"; String page_id = "1696073393958046"; String app_id = "105940229150066"; APIContext context = new APIContext(access_token).enableDebug(true); Campaign campaign = new AdAccount(ad_account_id, context).createCampaign() .setName("My Campaign") .setBuyingType("AUCTION") .setObjective(Campaign.EnumObjective.VALUE_PAGE_LIKES) .setStatus(Campaign.EnumStatus.VALUE_PAUSED) .execute(); String campaign_id = campaign.getId(); AdSet adSet = new AdAccount(ad_account_id, context).createAdSet() .setName("My AdSet") .setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_PAGE_LIKES) .setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS) .setBidAmount(20L) .setPromotedObject("{"page_id": "1696073393958046"}") .setDailyBudget(1000L) .setCampaignId(campaign_id) .setTargeting( new Targeting() .setFieldGeoLocations( new TargetingGeoLocation() .setFieldCountries(Arrays.asList("MXN")) ) ) .setStatus(AdSet.EnumStatus.VALUE_PAUSED) .execute(); String ad_set_id = adSet.getId(); AdCreative creative = new AdAccount(ad_account_id, context).createAdCreative() .setName("My Creative") .setObjectId(page_id) .setTitle("Page WebAd") .setBody("Like My Page") .setImageUrl("http://www.facebookmarketingdevelopers.com/static/images/resource_1.jpg") .execute(); String creative_id = creative.getId(); Ad ad = new AdAccount(ad_account_id, context).createAd() .setName("My Ad") .setAdsetId(ad_set_id) .setCreative( new AdCreative() .setFieldId(creative_id) ) .setStatus(Ad.EnumStatus.VALUE_PAUSED) .execute(); String ad_id = ad.getId(); new Ad(ad_id, context).getPreviews() .setAdFormat(AdPreview.EnumAdFormat.VALUE_DESKTOP_FEED_STANDARD) .execute(); } }APIContext