/
ad_account_ad_sets_post_page_likes.js
50 lines (46 loc) · 1.31 KB
/
ad_account_ad_sets_post_page_likes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
* @flow
*/
'use strict';
const bizSdk = require('facebook-nodejs-business-sdk');
const AdAccount = bizSdk.AdAccount;
const AdSet = bizSdk.AdSet;
const access_token = '<ACCESS_TOKEN>';
const app_secret = '<APP_SECRET>';
const app_id = '<APP_ID>';
const id = '<AD_ACCOUNT_ID>';
const api = bizSdk.FacebookAdsApi.init(access_token);
const showDebugingInfo = true; // Setting this to true shows more debugging info.
if (showDebugingInfo) {
api.setDebug(true);
}
const logApiCallResult = (apiCallName, data) => {
console.log(apiCallName);
if (showDebugingInfo) {
console.log('Data:' + JSON.stringify(data));
}
};
let fields, params;
fields = [
];
params = {
'name' : 'My Reach Ad Set',
'optimization_goal' : 'REACH',
'billing_event' : 'IMPRESSIONS',
'bid_amount' : '2',
'daily_budget' : '1000',
'campaign_id' : '<adCampaignLinkClicksID>',
'targeting' : {'geo_locations':{'countries':['US']},'facebook_positions':['feed']},
'status' : 'PAUSED',
'promoted_object' : {'page_id':'<pageID>'},
};
const adsets = (new AdAccount(id)).createAdSet(
fields,
params
);
logApiCallResult('adsets api call complete.', adsets);