diff --git a/examples/ad_account_ad_creatives_edge.js b/examples/ad_account_ad_creatives_edge.js new file mode 100644 index 00000000..7ec49c9a --- /dev/null +++ b/examples/ad_account_ad_creatives_edge.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', +]; +params = { +}; +const adcreativess = (new AdAccount(id)).getAdCreatives( + fields, + params +); +logApiCallResult('adcreativess api call complete.', adcreativess); \ No newline at end of file diff --git a/examples/ad_account_ad_creatives_post.js b/examples/ad_account_ad_creatives_post.js new file mode 100644 index 00000000..34e36a06 --- /dev/null +++ b/examples/ad_account_ad_creatives_post.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Sample Promoted Post', + 'object_story_id' : '_', +}; +const adcreatives = (new AdAccount(id)).createAdCreative( + fields, + params +); +logApiCallResult('adcreatives api call complete.', adcreatives); \ No newline at end of file diff --git a/examples/ad_account_ad_creatives_post_create_ad_creative.js b/examples/ad_account_ad_creatives_post_create_ad_creative.js new file mode 100644 index 00000000..dc1dc27d --- /dev/null +++ b/examples/ad_account_ad_creatives_post_create_ad_creative.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'object_story_id' : '_', +}; +const adcreatives = (new AdAccount(id)).createAdCreative( + fields, + params +); +logApiCallResult('adcreatives api call complete.', adcreatives); \ No newline at end of file diff --git a/examples/ad_account_ad_creatives_post_create_ad_creative_canvas.js b/examples/ad_account_ad_creatives_post_create_ad_creative_canvas.js new file mode 100644 index 00000000..5556c27d --- /dev/null +++ b/examples/ad_account_ad_creatives_post_create_ad_creative_canvas.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'image_hash' : '', + 'object_story_spec' : {'page_id':'','link_data':{'image_hash':'','link':'','name':'Creative message','call_to_action':{'type':'LEARN_MORE'}}}, +}; +const adcreatives = (new AdAccount(id)).createAdCreative( + fields, + params +); +logApiCallResult('adcreatives api call complete.', adcreatives); \ No newline at end of file diff --git a/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_d_v.js b/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_d_v.js new file mode 100644 index 00000000..cfdad9c0 --- /dev/null +++ b/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_d_v.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'object_story_spec' : {'page_id':'','template_data':{'format_option':'collection_video','link':'','name':'English Creative title','message':'English Creative message','call_to_action':{'type':'LEARN_MORE'},'retailer_item_ids':[0,0,0,0],'customization_rules_spec':[{'customization_spec':{'language':'en_XX'}},{'customization_spec':{'language':'fr_XX'},'link':'','name':'French Creative title','message':'French Creative message'}]}}, + 'product_set_id' : '', +}; +const adcreatives = (new AdAccount(id)).createAdCreative( + fields, + params +); +logApiCallResult('adcreatives api call complete.', adcreatives); \ No newline at end of file diff --git a/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_image.js b/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_image.js new file mode 100644 index 00000000..6a855b19 --- /dev/null +++ b/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_image.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'object_story_spec' : {'page_id':'','link_data':{'picture':'','link':'','name':'English Creative title','message':'English Creative message','call_to_action':{'type':'LEARN_MORE'},'retailer_item_ids':[0,0,0,0],'customization_rules_spec':[{'customization_spec':{'language':'en_XX'}},{'customization_spec':{'language':'fr_XX'},'picture':'','link':'','name':'French Creative title','message':'French Creative message'}]}}, + 'product_set_id' : '', +}; +const adcreatives = (new AdAccount(id)).createAdCreative( + fields, + params +); +logApiCallResult('adcreatives api call complete.', adcreatives); \ No newline at end of file diff --git a/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_video.js b/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_video.js new file mode 100644 index 00000000..b701c819 --- /dev/null +++ b/examples/ad_account_ad_creatives_post_create_ad_creative_customization_canvas_video.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'object_story_spec' : {'page_id':'','video_data':{'video_id':'','image_url':'','title':'English Creative title','message':'English Creative message','call_to_action':{'type':'LEARN_MORE','value':{'link':''}},'retailer_item_ids':[0,0,0,0],'customization_rules_spec':[{'customization_spec':{'language':'en_XX'}},{'customization_spec':{'language':'fr_XX'},'video_id':'','picture':'','link':'','name':'French Creative title','message':'French Creative message'}]}}, + 'product_set_id' : '', +}; +const adcreatives = (new AdAccount(id)).createAdCreative( + fields, + params +); +logApiCallResult('adcreatives api call complete.', adcreatives); \ No newline at end of file diff --git a/examples/ad_account_ad_creatives_post_enroll_status.js b/examples/ad_account_ad_creatives_post_enroll_status.js new file mode 100644 index 00000000..d676cac2 --- /dev/null +++ b/examples/ad_account_ad_creatives_post_enroll_status.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Sample Promoted', + 'object_story_spec' : {'page_id':'','link_data':{'image_hash':'','link':'','message':'try it out'}}, + 'degrees_of_freedom_spec' : {'creative_features_spec':'{\'standard_enhancements\':\'{\\\'enroll_status\\\':\\\'OPT_IN\\\'}\'}'}, + 'special_ad_categories' : [], +}; +const adcreatives = (new AdAccount(id)).createAdCreative( + fields, + params +); +logApiCallResult('adcreatives api call complete.', adcreatives); \ No newline at end of file diff --git a/examples/ad_account_ad_labels_post.js b/examples/ad_account_ad_labels_post.js new file mode 100644 index 00000000..7b6e7ebb --- /dev/null +++ b/examples/ad_account_ad_labels_post.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdLabel = bizSdk.AdLabel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Label', +}; +const adlabels = (new AdAccount(id)).createAdLabel( + fields, + params +); +logApiCallResult('adlabels api call complete.', adlabels); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_edge.js b/examples/ad_account_ad_sets_edge.js new file mode 100644 index 00000000..1ada0478 --- /dev/null +++ b/examples/ad_account_ad_sets_edge.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'id', + 'status', +]; +params = { +}; +const adsetss = (new AdAccount(id)).getAdSets( + fields, + params +); +logApiCallResult('adsetss api call complete.', adsetss); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_ad_set_create_cpa.js b/examples/ad_account_ad_sets_post_ad_set_create_cpa.js new file mode 100644 index 00000000..67c8e568 --- /dev/null +++ b/examples/ad_account_ad_sets_post_ad_set_create_cpa.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'A CPA Ad Set', + 'campaign_id' : '', + 'daily_budget' : '5000', + 'start_time' : '2024-07-27T00:47:13-0700', + 'end_time' : '2024-08-03T00:47:13-0700', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'REACH', + 'bid_amount' : '1000', + 'promoted_object' : {'page_id':''}, + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US']}}, + 'user_os' : 'iOS', + 'publisher_platforms' : 'facebook', + 'device_platforms' : 'mobile', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_ad_set_create_cpa_app_events.js b/examples/ad_account_ad_sets_post_ad_set_create_cpa_app_events.js new file mode 100644 index 00000000..91e80a5e --- /dev/null +++ b/examples/ad_account_ad_sets_post_ad_set_create_cpa_app_events.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'A CPA Ad Set optimized for App Events', + 'campaign_id' : '', + 'daily_budget' : '300', + 'start_time' : '2024-08-05T17:55:15-0700', + 'end_time' : '2024-08-12T17:55:15-0700', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'OFFSITE_CONVERSIONS', + 'bid_amount' : '100', + 'status' : 'PAUSED', + 'promoted_object' : {'application_id':'','object_store_url':'','custom_event_type':'PURCHASE'}, + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US']},'user_os':['iOS']}, +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_behavior_targeting.js b/examples/ad_account_ad_sets_post_behavior_targeting.js new file mode 100644 index 00000000..10985251 --- /dev/null +++ b/examples/ad_account_ad_sets_post_behavior_targeting.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 AdSet', + 'optimization_goal' : 'REACH', + 'billing_event' : 'IMPRESSIONS', + 'bid_amount' : '2', + 'daily_budget' : '1000', + 'campaign_id' : '', + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US']},'behaviors':[{'id':6007101597783,'name':'Business Travelers'},{'id':6004386044572,'name':'Android Owners (All)'}]}, +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_bid_multiplier.js b/examples/ad_account_ad_sets_post_bid_multiplier.js new file mode 100644 index 00000000..f0e0102b --- /dev/null +++ b/examples/ad_account_ad_sets_post_bid_multiplier.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 Adset with bid multiplier', + 'campaign_id' : '', + 'daily_budget' : '3000', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'OFFSITE_CONVERSIONS', + 'bid_amount' : '500', + 'bid_adjustments' : {'user_groups':{'gender':{'male':0.8,'female':1}}}, + 'promoted_object' : {'product_set_id':'','custom_event_type':'ADD_TO_CART'}, + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US']}}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_create_ad_set.js b/examples/ad_account_ad_sets_post_create_ad_set.js new file mode 100644 index 00000000..7ec59199 --- /dev/null +++ b/examples/ad_account_ad_sets_post_create_ad_set.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 First AdSet', + 'lifetime_budget' : '20000', + 'start_time' : '2024-07-27T00:46:29-0700', + 'end_time' : '2024-08-03T00:46:29-0700', + 'campaign_id' : '', + 'bid_amount' : '500', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'POST_ENGAGEMENT', + 'targeting' : {'age_min':20,'age_max':24,'behaviors':[{'id':6002714895372,'name':'All travelers'}],'genders':[1],'geo_locations':{'countries':['US'],'regions':[{'key':'4081'}],'cities':[{'key':'777934','radius':10,'distance_unit':'mile'}]},'interests':[{'id':'','name':''}],'life_events':[{'id':6002714398172,'name':'Newlywed (1 year)'}],'facebook_positions':['feed'],'publisher_platforms':['facebook','audience_network']}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_create_audience_network.js b/examples/ad_account_ad_sets_post_create_audience_network.js new file mode 100644 index 00000000..532c0a55 --- /dev/null +++ b/examples/ad_account_ad_sets_post_create_audience_network.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 Ad Set', + 'optimization_goal' : 'LINK_CLICKS', + 'billing_event' : 'LINK_CLICKS', + 'bid_amount' : '2', + 'daily_budget' : '1000', + 'campaign_id' : '', + 'targeting' : {'device_platforms':['mobile'],'geo_locations':{'countries':['US']},'publisher_platforms':['facebook','audience_network'],'facebook_positions':['feed']}, +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_create_m_a_i_a.js b/examples/ad_account_ad_sets_post_create_m_a_i_a.js new file mode 100644 index 00000000..4bb62e14 --- /dev/null +++ b/examples/ad_account_ad_sets_post_create_m_a_i_a.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Mobile App Installs Ad Set', + 'daily_budget' : '1000', + 'bid_amount' : '2', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'APP_INSTALLS', + 'campaign_id' : '', + 'promoted_object' : {'application_id':'','object_store_url':''}, + 'targeting' : {'device_platforms':['mobile'],'facebook_positions':['feed'],'geo_locations':{'countries':['US']},'publisher_platforms':['facebook','audience_network'],'user_os':['IOS']}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_daily_budget20.js b/examples/ad_account_ad_sets_post_daily_budget20.js new file mode 100644 index 00000000..befa5432 --- /dev/null +++ b/examples/ad_account_ad_sets_post_daily_budget20.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Adset', + 'daily_budget' : '2000', + 'start_time' : '2024-07-29T17:54:47-0700', + 'end_time' : '2024-08-05T17:54:47-0700', + 'campaign_id' : '', + 'bid_amount' : '100', + 'billing_event' : 'LINK_CLICKS', + 'optimization_goal' : 'LINK_CLICKS', + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US']}}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_demographic_targeting.js b/examples/ad_account_ad_sets_post_demographic_targeting.js new file mode 100644 index 00000000..e82adecc --- /dev/null +++ b/examples/ad_account_ad_sets_post_demographic_targeting.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 First AdSet', + 'daily_budget' : '10000', + 'bid_amount' : '300', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'REACH', + 'campaign_id' : '', + 'promoted_object' : {'page_id':''}, + 'targeting' : {'facebook_positions':['feed'],'age_max':24,'age_min':20,'behaviors':[{'id':6002714895372,'name':'All travelers'}],'device_platforms':['mobile'],'genders':[1],'geo_locations':{'countries':['US'],'regions':[{'key':'4081'}],'cities':[{'key':777934,'radius':10,'distance_unit':'mile'}]},'interests':[{'id':'','name':''}],'life_events':[{'id':6002714398172,'name':'Newlywed (1 year)'}],'publisher_platforms':['facebook','audience_network']}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_interest_targeting.js b/examples/ad_account_ad_sets_post_interest_targeting.js new file mode 100644 index 00000000..f4af5956 --- /dev/null +++ b/examples/ad_account_ad_sets_post_interest_targeting.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 First AdSet', + 'daily_budget' : '10000', + 'bid_amount' : '300', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'REACH', + 'campaign_id' : '', + 'promoted_object' : {'page_id':''}, + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US'],'regions':[{'key':'4081'}],'cities':[{'key':777934,'radius':10,'distance_unit':'mile'}]},'genders':[1],'age_max':24,'age_min':20,'publisher_platforms':['facebook','audience_network'],'device_platforms':['mobile'],'flexible_spec':[{'interests':[{'id':'','name':''}]}]}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_lifetime_budget200_duration10_days.js b/examples/ad_account_ad_sets_post_lifetime_budget200_duration10_days.js new file mode 100644 index 00000000..a6bc9b81 --- /dev/null +++ b/examples/ad_account_ad_sets_post_lifetime_budget200_duration10_days.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Adset', + 'lifetime_budget' : '20000', + 'start_time' : '2024-07-29T17:54:57-0700', + 'end_time' : '2024-08-08T17:54:57-0700', + 'campaign_id' : '', + 'bid_amount' : '100', + 'billing_event' : 'LINK_CLICKS', + 'optimization_goal' : 'LINK_CLICKS', + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US']},'publisher_platforms':['facebook','audience_network']}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_optimize_post_engagement.js b/examples/ad_account_ad_sets_post_optimize_post_engagement.js new file mode 100644 index 00000000..74a9a884 --- /dev/null +++ b/examples/ad_account_ad_sets_post_optimize_post_engagement.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Adset', + 'lifetime_budget' : '20000', + 'start_time' : '2024-07-29T17:55:06-0700', + 'end_time' : '2024-08-08T17:55:06-0700', + 'campaign_id' : '', + 'bid_amount' : '500', + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'POST_ENGAGEMENT', + 'targeting' : {'facebook_positions':['feed'],'geo_locations':{'countries':['US'],'regions':[{'key':'4081'}],'cities':[{'key':777934,'radius':10,'distance_unit':'mile'}]},'genders':[1],'age_max':24,'age_min':20,'behaviors':[{'id':6002714895372,'name':'All travelers'}],'life_events':[{'id':6002714398172,'name':'Newlywed (1 year)'}],'publisher_platforms':['facebook'],'device_platforms':['desktop']}, + 'status' : 'PAUSED', +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_page_likes.js b/examples/ad_account_ad_sets_post_page_likes.js new file mode 100644 index 00000000..3fd8368e --- /dev/null +++ b/examples/ad_account_ad_sets_post_page_likes.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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' : '', + 'targeting' : {'geo_locations':{'countries':['US']},'facebook_positions':['feed']}, + 'status' : 'PAUSED', + 'promoted_object' : {'page_id':''}, +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_placement_targeting.js b/examples/ad_account_ad_sets_post_placement_targeting.js new file mode 100644 index 00000000..a8265b85 --- /dev/null +++ b/examples/ad_account_ad_sets_post_placement_targeting.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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 AdSet', + 'optimization_goal' : 'REACH', + 'billing_event' : 'IMPRESSIONS', + 'bid_amount' : '2', + 'daily_budget' : '1000', + 'campaign_id' : '', + 'targeting' : {'geo_locations':{'countries':['US']},'publisher_platforms':['facebook'],'facebook_positions':['feed']}, + 'promoted_object' : {'page_id':''}, +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_sets_post_reach.js b/examples/ad_account_ad_sets_post_reach.js new file mode 100644 index 00000000..39e0a11f --- /dev/null +++ b/examples/ad_account_ad_sets_post_reach.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 = ''; +const app_secret = ''; +const app_id = ''; +const 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' : '', + 'targeting' : {'excluded_geo_locations':{'regions':[{'key':'3847'}]},'geo_locations':{'countries':['US']},'facebook_positions':['feed']}, + 'status' : 'PAUSED', + 'promoted_object' : {'page_id':''}, +}; +const adsets = (new AdAccount(id)).createAdSet( + fields, + params +); +logApiCallResult('adsets api call complete.', adsets); \ No newline at end of file diff --git a/examples/ad_account_ad_videos_post.js b/examples/ad_account_ad_videos_post.js new file mode 100644 index 00000000..2806d7ea --- /dev/null +++ b/examples/ad_account_ad_videos_post.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdVideo = bizSdk.AdVideo; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'source' : '', +}; +const advideos = (new AdAccount(id)).createAdVideo( + fields, + params +); +logApiCallResult('advideos api call complete.', advideos); \ No newline at end of file diff --git a/examples/ad_account_ads_edge.js b/examples/ad_account_ads_edge.js new file mode 100644 index 00000000..512bd95c --- /dev/null +++ b/examples/ad_account_ads_edge.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'id', +]; +params = { +}; +const adss = (new AdAccount(id)).getAds( + fields, + params +); +logApiCallResult('adss api call complete.', adss); \ No newline at end of file diff --git a/examples/ad_account_ads_pixel_edge_get_pixel_code.js b/examples/ad_account_ads_pixel_edge_get_pixel_code.js new file mode 100644 index 00000000..5f616e38 --- /dev/null +++ b/examples/ad_account_ads_pixel_edge_get_pixel_code.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdsPixel = bizSdk.AdsPixel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'code', +]; +params = { +}; +const sample_code = (new AdsPixel(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_account_ads_pixels_post.js b/examples/ad_account_ads_pixels_post.js new file mode 100644 index 00000000..da41dba9 --- /dev/null +++ b/examples/ad_account_ads_pixels_post.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdsPixel = bizSdk.AdsPixel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 WCA Pixel', +}; +const adspixels = (new AdAccount(id)).createAdsPixel( + fields, + params +); +logApiCallResult('adspixels api call complete.', adspixels); \ No newline at end of file diff --git a/examples/ad_account_ads_post.js b/examples/ad_account_ads_post.js new file mode 100644 index 00000000..085b1d84 --- /dev/null +++ b/examples/ad_account_ads_post.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Ad', + 'adset_id' : '', + 'creative' : {'creative_id':''}, + 'status' : 'PAUSED', +}; +const ads = (new AdAccount(id)).createAd( + fields, + params +); +logApiCallResult('ads api call complete.', ads); \ No newline at end of file diff --git a/examples/ad_account_ads_post_ads_redownload.js b/examples/ad_account_ads_post_ads_redownload.js new file mode 100644 index 00000000..efa654a4 --- /dev/null +++ b/examples/ad_account_ads_post_ads_redownload.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 AdGroup with Redownload', + 'adset_id' : '', + 'creative' : {'creative_id':''}, + 'redownload' : '1', + 'status' : 'PAUSED', +}; +const ads = (new AdAccount(id)).createAd( + fields, + params +); +logApiCallResult('ads api call complete.', ads); \ No newline at end of file diff --git a/examples/ad_account_ads_post_authorization_category.js b/examples/ad_account_ads_post_authorization_category.js new file mode 100644 index 00000000..07171496 --- /dev/null +++ b/examples/ad_account_ads_post_authorization_category.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 AdGroup', + 'adset_id' : '', + 'creative' : {'creative_id':''}, + 'status' : 'PAUSED', + 'authorization_category' : 'POLITICAL', +}; +const ads = (new AdAccount(id)).createAd( + fields, + params +); +logApiCallResult('ads api call complete.', ads); \ No newline at end of file diff --git a/examples/ad_account_ads_post_tracking_post_engagement.js b/examples/ad_account_ads_post_tracking_post_engagement.js new file mode 100644 index 00000000..c90f8b2f --- /dev/null +++ b/examples/ad_account_ads_post_tracking_post_engagement.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Ad', + 'adset_id' : '', + 'creative' : {'creative_id':''}, + 'tracking_specs' : {'action.type':'post_engagement','post':'','page':''}, + 'status' : 'PAUSED', +}; +const ads = (new AdAccount(id)).createAd( + fields, + params +); +logApiCallResult('ads api call complete.', ads); \ No newline at end of file diff --git a/examples/ad_account_campaigns_edge.js b/examples/ad_account_campaigns_edge.js new file mode 100644 index 00000000..c0830821 --- /dev/null +++ b/examples/ad_account_campaigns_edge.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'objective', +]; +params = { + 'effective_status' : ['ACTIVE','PAUSED'], +}; +const campaignss = (new AdAccount(id)).getCampaigns( + fields, + params +); +logApiCallResult('campaignss api call complete.', campaignss); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post.js b/examples/ad_account_campaigns_post.js new file mode 100644 index 00000000..f18eff7f --- /dev/null +++ b/examples/ad_account_campaigns_post.js @@ -0,0 +1,175 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 campaign', + 'objective' : 'OUTCOME_TRAFFIC', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'Lead generation campaign', + 'objective' : 'OUTCOME_LEADS', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'Local ad campaign', + 'objective' : 'OUTCOME_AWARENESS', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'Mobile App Installs Campaign', + 'objective' : 'OUTCOME_APP_PROMOTION', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'App Installs Campaign with Dynamic Product Ads', + 'objective' : 'OUTCOME_APP_PROMOTION', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'Video Views campaign', + 'objective' : 'OUTCOME_ENGAGEMENT', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'My First Campaign', + 'objective' : 'OUTCOME_ENGAGEMENT', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'My First Campaign', + 'objective' : 'OUTCOME_ENGAGEMENT', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'My First Campaign with daily budget', + 'objective' : 'OUTCOME_LEADS', + 'status' : 'PAUSED', + 'daily_budget' : '1000', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); + +fields = [ +]; +params = { + 'name' : 'My First Campaign with special ad categories', + 'objective' : 'OUTCOME_LEADS', + 'status' : 'PAUSED', + 'daily_budget' : '1000', + 'special_ad_categories' : [], + 'special_ad_category_country' : ['MX'], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_categories.js b/examples/ad_account_campaigns_post_categories.js new file mode 100644 index 00000000..4bb48176 --- /dev/null +++ b/examples/ad_account_campaigns_post_categories.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Campaign with special ad categories', + 'objective' : 'OUTCOME_LEADS', + 'status' : 'PAUSED', + 'daily_budget' : '1000', + 'special_ad_categories' : [], + 'special_ad_category_country' : ['MX'], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_daily_budget.js b/examples/ad_account_campaigns_post_daily_budget.js new file mode 100644 index 00000000..9f2ba229 --- /dev/null +++ b/examples/ad_account_campaigns_post_daily_budget.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Campaign with daily budget', + 'objective' : 'OUTCOME_LEADS', + 'status' : 'PAUSED', + 'daily_budget' : '1000', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_lead_gen.js b/examples/ad_account_campaigns_post_lead_gen.js new file mode 100644 index 00000000..1e7ab8c1 --- /dev/null +++ b/examples/ad_account_campaigns_post_lead_gen.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Lead generation campaign', + 'objective' : 'OUTCOME_LEADS', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_link_clicks.js b/examples/ad_account_campaigns_post_link_clicks.js new file mode 100644 index 00000000..6acdf191 --- /dev/null +++ b/examples/ad_account_campaigns_post_link_clicks.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 campaign', + 'objective' : 'OUTCOME_TRAFFIC', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_local_awareness.js b/examples/ad_account_campaigns_post_local_awareness.js new file mode 100644 index 00000000..cf5ffb72 --- /dev/null +++ b/examples/ad_account_campaigns_post_local_awareness.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Local ad campaign', + 'objective' : 'OUTCOME_AWARENESS', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_m_a_i_a.js b/examples/ad_account_campaigns_post_m_a_i_a.js new file mode 100644 index 00000000..de7c88b0 --- /dev/null +++ b/examples/ad_account_campaigns_post_m_a_i_a.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Mobile App Installs Campaign', + 'objective' : 'OUTCOME_APP_PROMOTION', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_m_a_i_d_p_a.js b/examples/ad_account_campaigns_post_m_a_i_d_p_a.js new file mode 100644 index 00000000..d28bd943 --- /dev/null +++ b/examples/ad_account_campaigns_post_m_a_i_d_p_a.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'App Installs Campaign with Dynamic Product Ads', + 'objective' : 'OUTCOME_APP_PROMOTION', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_page_likes.js b/examples/ad_account_campaigns_post_page_likes.js new file mode 100644 index 00000000..7b42b7a5 --- /dev/null +++ b/examples/ad_account_campaigns_post_page_likes.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Campaign', + 'objective' : 'OUTCOME_ENGAGEMENT', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_post_engagement.js b/examples/ad_account_campaigns_post_post_engagement.js new file mode 100644 index 00000000..7b42b7a5 --- /dev/null +++ b/examples/ad_account_campaigns_post_post_engagement.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 First Campaign', + 'objective' : 'OUTCOME_ENGAGEMENT', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_campaigns_post_video_views.js b/examples/ad_account_campaigns_post_video_views.js new file mode 100644 index 00000000..01191908 --- /dev/null +++ b/examples/ad_account_campaigns_post_video_views.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Video Views campaign', + 'objective' : 'OUTCOME_ENGAGEMENT', + 'status' : 'PAUSED', + 'special_ad_categories' : [], +}; +const campaigns = (new AdAccount(id)).createCampaign( + fields, + params +); +logApiCallResult('campaigns api call complete.', campaigns); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_edge.js b/examples/ad_account_custom_audiences_edge.js new file mode 100644 index 00000000..bc29d394 --- /dev/null +++ b/examples/ad_account_custom_audiences_edge.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'id', +]; +params = { +}; +const customaudiencess = (new AdAccount(id)).getCustomAudiences( + fields, + params +); +logApiCallResult('customaudiencess api call complete.', customaudiencess); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_edge_data_source_subtype.js b/examples/ad_account_custom_audiences_edge_data_source_subtype.js new file mode 100644 index 00000000..11e341d5 --- /dev/null +++ b/examples/ad_account_custom_audiences_edge_data_source_subtype.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'data_source', + 'subtype', +]; +params = { +}; +const customaudiencess = (new AdAccount(id)).getCustomAudiences( + fields, + params +); +logApiCallResult('customaudiencess api call complete.', customaudiencess); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_create_custom_audience.js b/examples/ad_account_custom_audiences_post_create_custom_audience.js new file mode 100644 index 00000000..37877f0e --- /dev/null +++ b/examples/ad_account_custom_audiences_post_create_custom_audience.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 new Custom Audience', + 'subtype' : 'CUSTOM', + 'description' : 'People who purchased on my website', + 'customer_file_source' : 'USER_PROVIDED_ONLY', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_dynamic_event_value_based_lookalike_custom_audience.js b/examples/ad_account_custom_audiences_post_dynamic_event_value_based_lookalike_custom_audience.js new file mode 100644 index 00000000..67e1674d --- /dev/null +++ b/examples/ad_account_custom_audiences_post_dynamic_event_value_based_lookalike_custom_audience.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Test Value-Based lookalike from Pixel', + 'subtype' : 'LOOKALIKE', + 'lookalike_spec' : {'origin_event_sources':[{'id':'','event_names':['AddToCart']}],'type':'custom_ratio','ratio':0.01,'country':'US'}, +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_dynamic_value_based_lookalike_custom_audience.js b/examples/ad_account_custom_audiences_post_dynamic_value_based_lookalike_custom_audience.js new file mode 100644 index 00000000..b083abf5 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_dynamic_value_based_lookalike_custom_audience.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Test Value-Based lookalike from Pixel', + 'subtype' : 'LOOKALIKE', + 'lookalike_spec' : {'origin_event_sources':[{'id':''}],'type':'custom_ratio','ratio':0.01,'country':'US'}, +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_platform_custom_audience_m_a_c_a_rule.js b/examples/ad_account_custom_audiences_post_platform_custom_audience_m_a_c_a_rule.js new file mode 100644 index 00000000..04c04911 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_platform_custom_audience_m_a_c_a_rule.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Test Website Custom Audience', + 'rule' : {'inclusions':{'operator':'or','rules':[{'event_sources':[{'id':'','type':'app'}],'retention_seconds':8400,'filter':{'operator':'and','filters':[{'field':'event','operator':'eq','value':'fb_mobile_purchase'}]}}]}}, + 'prefill' : '1', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_platform_e_c_a_exclusions.js b/examples/ad_account_custom_audiences_post_platform_e_c_a_exclusions.js new file mode 100644 index 00000000..18d810c2 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_platform_e_c_a_exclusions.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Test Engagement Custom Audience', + 'rule' : {'inclusions':{'operator':'or','rules':[{'event_sources':[{'id':'','type':'page'}],'retention_seconds':31536000,'filter':{'operator':'and','filters':[{'field':'event','operator':'eq','value':'page_engaged'}]}}]},'exclusions':{'operator':'or','rules':[{'event_sources':[{'id':'','type':'page'}],'retention_seconds':31536000,'filter':{'operator':'and','filters':[{'field':'event','operator':'eq','value':'page_cta_clicked'}]}}]}}, + 'prefill' : '1', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_platform_e_c_a_multi_filters.js b/examples/ad_account_custom_audiences_post_platform_e_c_a_multi_filters.js new file mode 100644 index 00000000..a3e08ce1 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_platform_e_c_a_multi_filters.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Test Engagement Custom Audience', + 'rule' : {'inclusions':{'operator':'or','rules':[{'event_sources':[{'id':'','type':'page'}],'retention_seconds':31536000,'filter':{'operator':'and','filters':[{'field':'event','operator':'eq','value':'page_engaged'},{'field':'event','operator':'eq','value':'page_engaged'}]}}]}}, + 'prefill' : '1', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_platform_e_c_a_multi_pages.js b/examples/ad_account_custom_audiences_post_platform_e_c_a_multi_pages.js new file mode 100644 index 00000000..14bc6df9 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_platform_e_c_a_multi_pages.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Test Engagement Custom Audience', + 'rule' : {'inclusions':{'operator':'or','rules':[{'event_sources':[{'id':'','type':'page'},{'id':'','type':'page'}],'retention_seconds':31536000,'filter':{'operator':'and','filters':[{'field':'event','operator':'eq','value':'page_engaged'}]}}]}}, + 'prefill' : '1', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_platform_engagement_custom_audience.js b/examples/ad_account_custom_audiences_post_platform_engagement_custom_audience.js new file mode 100644 index 00000000..4e3037d4 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_platform_engagement_custom_audience.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Test Engagement Custom Audience', + 'rule' : {'inclusions':{'operator':'or','rules':[{'event_sources':[{'id':'','type':'page'}],'retention_seconds':31536000,'filter':{'operator':'and','filters':[{'field':'event','operator':'eq','value':'page_engaged'}]}}]}}, + 'prefill' : '1', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_platform_website_custom_audience.js b/examples/ad_account_custom_audiences_post_platform_website_custom_audience.js new file mode 100644 index 00000000..935cf31e --- /dev/null +++ b/examples/ad_account_custom_audiences_post_platform_website_custom_audience.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Test Website Custom Audience', + 'rule' : {'inclusions':{'operator':'or','rules':[{'event_sources':[{'id':'','type':'pixel'}],'retention_seconds':8400,'filter':{'operator':'and','filters':[{'field':'url','operator':'i_contains','value':'shoes'}]}}]}}, + 'prefill' : '1', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_value_based_custom_audience.js b/examples/ad_account_custom_audiences_post_value_based_custom_audience.js new file mode 100644 index 00000000..b5596384 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_value_based_custom_audience.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Value-Based Custom Audience', + 'subtype' : 'CUSTOM', + 'is_value_based' : '1', + 'customer_file_source' : 'PARTNER_PROVIDED_ONLY', +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_custom_audiences_post_value_based_lookalike_custom_audience.js b/examples/ad_account_custom_audiences_post_value_based_lookalike_custom_audience.js new file mode 100644 index 00000000..ce67aa96 --- /dev/null +++ b/examples/ad_account_custom_audiences_post_value_based_lookalike_custom_audience.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Value-Based lookalike', + 'subtype' : 'LOOKALIKE', + 'origin_audience_id' : '', + 'lookalike_spec' : {'type':'custom_ratio','ratio':0.01,'country':'US'}, +}; +const customaudiences = (new AdAccount(id)).createCustomAudience( + fields, + params +); +logApiCallResult('customaudiences api call complete.', customaudiences); \ No newline at end of file diff --git a/examples/ad_account_generate_previews_edge.js b/examples/ad_account_generate_previews_edge.js new file mode 100644 index 00000000..c24a6557 --- /dev/null +++ b/examples/ad_account_generate_previews_edge.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'creative' : '', + 'ad_format' : '', +}; +const generatepreviewss = (new AdAccount(id)).getGeneratePreviews( + fields, + params +); +logApiCallResult('generatepreviewss api call complete.', generatepreviewss); \ No newline at end of file diff --git a/examples/ad_account_generate_previews_edge_desktop_with_story_id.js b/examples/ad_account_generate_previews_edge_desktop_with_story_id.js new file mode 100644 index 00000000..957d9bd9 --- /dev/null +++ b/examples/ad_account_generate_previews_edge_desktop_with_story_id.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'creative' : {'object_story_id':'_'}, + 'ad_format' : 'DESKTOP_FEED_STANDARD', +}; +const generatepreviewss = (new AdAccount(id)).getGeneratePreviews( + fields, + params +); +logApiCallResult('generatepreviewss api call complete.', generatepreviewss); \ No newline at end of file diff --git a/examples/ad_account_generate_previews_edge_instagram_standards.js b/examples/ad_account_generate_previews_edge_instagram_standards.js new file mode 100644 index 00000000..f547a609 --- /dev/null +++ b/examples/ad_account_generate_previews_edge_instagram_standards.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'creative' : {'instagram_actor_id':'','object_story_spec':{'link_data':{'call_to_action':{'type':'LEARN_MORE','value':{'link':''}},'caption':'www.example.com','image_hash':'','link':'','message':'Message'},'page_id':''}}, + 'ad_format' : 'INSTAGRAM_STANDARD', +}; +const generatepreviewss = (new AdAccount(id)).getGeneratePreviews( + fields, + params +); +logApiCallResult('generatepreviewss api call complete.', generatepreviewss); \ No newline at end of file diff --git a/examples/ad_account_generate_previews_edge_maia_with_object_story_spec.js b/examples/ad_account_generate_previews_edge_maia_with_object_story_spec.js new file mode 100644 index 00000000..749d9264 --- /dev/null +++ b/examples/ad_account_generate_previews_edge_maia_with_object_story_spec.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'creative' : {'object_story_spec':{'link_data':{'call_to_action':{'type':'USE_APP','value':{'link':''}},'description':'Description','link':'','message':'Message','name':'Name','picture':''},'page_id':''}}, + 'ad_format' : 'MOBILE_FEED_STANDARD', +}; +const generatepreviewss = (new AdAccount(id)).getGeneratePreviews( + fields, + params +); +logApiCallResult('generatepreviewss api call complete.', generatepreviewss); \ No newline at end of file diff --git a/examples/ad_account_node.js b/examples/ad_account_node.js new file mode 100644 index 00000000..015a4dbe --- /dev/null +++ b/examples/ad_account_node.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', +]; +params = { +}; +const sample_code = (new AdAccount(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_account_product_audiences_post_iphone_view_no_purchase.js b/examples/ad_account_product_audiences_post_iphone_view_no_purchase.js new file mode 100644 index 00000000..390a1e7d --- /dev/null +++ b/examples/ad_account_product_audiences_post_iphone_view_no_purchase.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Test Iphone Product Audience', + 'product_set_id' : '', + 'inclusions' : [{'retention_seconds':86400,'rule':{'and':[{'event':{'eq':'AddToCart'}},{'userAgent':{'i_contains':'iPhone'}}]}}], + 'exclusions' : [{'retention_seconds':172800,'rule':{'event':{'eq':'Purchase'}}}], +}; +const product_audiences = (new AdAccount(id)).createProductAudience( + fields, + params +); +logApiCallResult('product_audiences api call complete.', product_audiences); \ No newline at end of file diff --git a/examples/ad_account_product_audiences_post_no_purchase.js b/examples/ad_account_product_audiences_post_no_purchase.js new file mode 100644 index 00000000..6ac32776 --- /dev/null +++ b/examples/ad_account_product_audiences_post_no_purchase.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Test Product Audience', + 'product_set_id' : '', + 'inclusions' : [{'retention_seconds':86400,'rule':{'event':{'eq':'AddToCart'}}},{'retention_seconds':72000,'rule':{'event':{'eq':'ViewContent'}}}], + 'exclusions' : [{'retention_seconds':172800,'rule':{'event':{'eq':'Purchase'}}}], +}; +const product_audiences = (new AdAccount(id)).createProductAudience( + fields, + params +); +logApiCallResult('product_audiences api call complete.', product_audiences); \ No newline at end of file diff --git a/examples/ad_account_reach_estimate.js b/examples/ad_account_reach_estimate.js new file mode 100644 index 00000000..4d98e2c2 --- /dev/null +++ b/examples/ad_account_reach_estimate.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdAccountReachEstimate = bizSdk.AdAccountReachEstimate; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'targeting_spec' : {'geo_locations':{'countries':['US']},'age_min':20,'age_max':40}, +}; +const reachestimates = (new AdAccount(id)).getReachEstimate( + fields, + params +); +logApiCallResult('reachestimates api call complete.', reachestimates); \ No newline at end of file diff --git a/examples/ad_campaign_ads_edge.js b/examples/ad_campaign_ads_edge.js new file mode 100644 index 00000000..4b08a466 --- /dev/null +++ b/examples/ad_campaign_ads_edge.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; +const Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'id', +]; +params = { +}; +const adss = (new AdSet(id)).getAds( + fields, + params +); +logApiCallResult('adss api call complete.', adss); \ No newline at end of file diff --git a/examples/ad_campaign_group_ads_edge.js b/examples/ad_campaign_group_ads_edge.js new file mode 100644 index 00000000..9bdcabeb --- /dev/null +++ b/examples/ad_campaign_group_ads_edge.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; +const Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', +]; +params = { +}; +const adss = (new Campaign(id)).getAds( + fields, + params +); +logApiCallResult('adss api call complete.', adss); \ No newline at end of file diff --git a/examples/ad_campaign_group_ads_edge_adgroups_with_status_archived.js b/examples/ad_campaign_group_ads_edge_adgroups_with_status_archived.js new file mode 100644 index 00000000..4893d9b2 --- /dev/null +++ b/examples/ad_campaign_group_ads_edge_adgroups_with_status_archived.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; +const Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', +]; +params = { + 'effective_status' : ['ARCHIVED'], +}; +const adss = (new Campaign(id)).getAds( + fields, + params +); +logApiCallResult('adss api call complete.', adss); \ No newline at end of file diff --git a/examples/ad_campaign_group_adsets_edge.js b/examples/ad_campaign_group_adsets_edge.js new file mode 100644 index 00000000..962b1e57 --- /dev/null +++ b/examples/ad_campaign_group_adsets_edge.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; +const AdSet = bizSdk.AdSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'start_time', + 'end_time', + 'daily_budget', + 'lifetime_budget', +]; +params = { +}; +const adsetss = (new Campaign(id)).getAdSets( + fields, + params +); +logApiCallResult('adsetss api call complete.', adsetss); \ No newline at end of file diff --git a/examples/ad_campaign_node.js b/examples/ad_campaign_node.js new file mode 100644 index 00000000..f6abbc08 --- /dev/null +++ b/examples/ad_campaign_node.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'adset_schedule', +]; +params = { +}; +const sample_code = (new AdSet(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_campaign_node_read.js b/examples/ad_campaign_node_read.js new file mode 100644 index 00000000..1e4f33c2 --- /dev/null +++ b/examples/ad_campaign_node_read.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'status', +]; +params = { +}; +const sample_code = (new AdSet(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_campaign_node_read_format_u_n_i_x.js b/examples/ad_campaign_node_read_format_u_n_i_x.js new file mode 100644 index 00000000..f57e0ab1 --- /dev/null +++ b/examples/ad_campaign_node_read_format_u_n_i_x.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'id', + 'name', + 'start_time', + 'end_time', +]; +params = { + 'date_format' : 'U', +}; +const sample_code = (new AdSet(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_campaign_post.js b/examples/ad_campaign_post.js new file mode 100644 index 00000000..91eb380f --- /dev/null +++ b/examples/ad_campaign_post.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'bid_adjustments' : {'user_groups':{'user_bucket':{'event_sources':['',''],'1':0.1,'2':0.2,'3':0.3,'default':{'gender':{'male':0.99,'female':0.12}}}}}, +}; +const sample_code = (new AdSet(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_campaign_post_adset_update_cpa.js b/examples/ad_campaign_post_adset_update_cpa.js new file mode 100644 index 00000000..e640ca5b --- /dev/null +++ b/examples/ad_campaign_post_adset_update_cpa.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'billing_event' : 'IMPRESSIONS', + 'optimization_goal' : 'LINK_CLICKS', + 'bid_amount' : '200', + 'targeting' : {'geo_locations':{'countries':['US']},'facebook_positions':['feed']}, +}; +const sample_code = (new AdSet(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_creative_node.js b/examples/ad_creative_node.js new file mode 100644 index 00000000..28ce1969 --- /dev/null +++ b/examples/ad_creative_node.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'asset_feed_spec', +]; +params = { +}; +const sample_code = (new AdCreative(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_creative_node_read.js b/examples/ad_creative_node_read.js new file mode 100644 index 00000000..3d959ccc --- /dev/null +++ b/examples/ad_creative_node_read.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'object_story_id', +]; +params = { +}; +const sample_code = (new AdCreative(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_creative_node_read_instagram_permalink_url.js b/examples/ad_creative_node_read_instagram_permalink_url.js new file mode 100644 index 00000000..2adc46ee --- /dev/null +++ b/examples/ad_creative_node_read_instagram_permalink_url.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'instagram_permalink_url', +]; +params = { +}; +const sample_code = (new AdCreative(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ad_creative_previews_edge.js b/examples/ad_creative_previews_edge.js new file mode 100644 index 00000000..160d086b --- /dev/null +++ b/examples/ad_creative_previews_edge.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; +const AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'ad_format' : 'DESKTOP_FEED_STANDARD', + 'product_item_ids' : [''], +}; +const previewss = (new AdCreative(id)).getPreviews( + fields, + params +); +logApiCallResult('previewss api call complete.', previewss); \ No newline at end of file diff --git a/examples/ad_creative_previews_edge_preview.js b/examples/ad_creative_previews_edge_preview.js new file mode 100644 index 00000000..f40d37f2 --- /dev/null +++ b/examples/ad_creative_previews_edge_preview.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; +const AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'ad_format' : 'DESKTOP_FEED_STANDARD', +}; +const previewss = (new AdCreative(id)).getPreviews( + fields, + params +); +logApiCallResult('previewss api call complete.', previewss); \ No newline at end of file diff --git a/examples/ad_creative_previews_edge_preview_dynamic_ads.js b/examples/ad_creative_previews_edge_preview_dynamic_ads.js new file mode 100644 index 00000000..160d086b --- /dev/null +++ b/examples/ad_creative_previews_edge_preview_dynamic_ads.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; +const AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'ad_format' : 'DESKTOP_FEED_STANDARD', + 'product_item_ids' : [''], +}; +const previewss = (new AdCreative(id)).getPreviews( + fields, + params +); +logApiCallResult('previewss api call complete.', previewss); \ No newline at end of file diff --git a/examples/ad_creative_previews_edge_preview_dynamic_ads_with_customizations.js b/examples/ad_creative_previews_edge_preview_dynamic_ads_with_customizations.js new file mode 100644 index 00000000..4c9edf5d --- /dev/null +++ b/examples/ad_creative_previews_edge_preview_dynamic_ads_with_customizations.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdCreative = bizSdk.AdCreative; +const AdPreview = bizSdk.AdPreview; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'ad_format' : 'DESKTOP_FEED_STANDARD', + 'product_item_ids' : [''], + 'dynamic_customization' : {'language':'fr_XX','country':'FR'}, +}; +const previewss = (new AdCreative(id)).getPreviews( + fields, + params +); +logApiCallResult('previewss api call complete.', previewss); \ No newline at end of file diff --git a/examples/ad_sets_delete.js b/examples/ad_sets_delete.js new file mode 100644 index 00000000..c8648250 --- /dev/null +++ b/examples/ad_sets_delete.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; +const AbstractObject = bizSdk.AbstractObject; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new AdSet(id)).delete( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/adgroup_delete.js b/examples/adgroup_delete.js new file mode 100644 index 00000000..26a7fc17 --- /dev/null +++ b/examples/adgroup_delete.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; +const AbstractObject = bizSdk.AbstractObject; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new Ad(id)).delete( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/adgroup_leads_edge_adgroup_leads.js b/examples/adgroup_leads_edge_adgroup_leads.js new file mode 100644 index 00000000..a90bc257 --- /dev/null +++ b/examples/adgroup_leads_edge_adgroup_leads.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; +const Lead = bizSdk.Lead; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const leadss = (new Ad(id)).getLeads( + fields, + params +); +logApiCallResult('leadss api call complete.', leadss); \ No newline at end of file diff --git a/examples/adgroup_leads_edge_adgroup_leads_d_p_a.js b/examples/adgroup_leads_edge_adgroup_leads_d_p_a.js new file mode 100644 index 00000000..6faf78a3 --- /dev/null +++ b/examples/adgroup_leads_edge_adgroup_leads_d_p_a.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; +const Lead = bizSdk.Lead; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'field_data', + 'retailer_item_id', +]; +params = { +}; +const leadss = (new Ad(id)).getLeads( + fields, + params +); +logApiCallResult('leadss api call complete.', leadss); \ No newline at end of file diff --git a/examples/adgroup_leads_edge_adgroup_leads_filtered.js b/examples/adgroup_leads_edge_adgroup_leads_filtered.js new file mode 100644 index 00000000..60a324e2 --- /dev/null +++ b/examples/adgroup_leads_edge_adgroup_leads_filtered.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; +const Lead = bizSdk.Lead; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'filtering' : [{'field':'time_created','operator':'GREATER_THAN','value':1721709809}], +}; +const leadss = (new Ad(id)).getLeads( + fields, + params +); +logApiCallResult('leadss api call complete.', leadss); \ No newline at end of file diff --git a/examples/adgroup_node.js b/examples/adgroup_node.js new file mode 100644 index 00000000..e9dd4ae9 --- /dev/null +++ b/examples/adgroup_node.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'id', + 'name', +]; +params = { +}; +const sample_code = (new Ad(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/adgroup_post.js b/examples/adgroup_post.js new file mode 100644 index 00000000..48f7c525 --- /dev/null +++ b/examples/adgroup_post.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 New Ad', +}; +const sample_code = (new Ad(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/adgroup_post_add_label.js b/examples/adgroup_post_add_label.js new file mode 100644 index 00000000..533725b9 --- /dev/null +++ b/examples/adgroup_post_add_label.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 New Ad with Label', + 'adlabels' : [{'id':'','name':'My Label'}], +}; +const sample_code = (new Ad(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/adgroup_post_update_status.js b/examples/adgroup_post_update_status.js new file mode 100644 index 00000000..6cb7002c --- /dev/null +++ b/examples/adgroup_post_update_status.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'adgroup_status' : 'PAUSED', +}; +const sample_code = (new Ad(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/ads_insights_edge_ad_campaign_insights.js b/examples/ads_insights_edge_ad_campaign_insights.js new file mode 100644 index 00000000..f5e76532 --- /dev/null +++ b/examples/ads_insights_edge_ad_campaign_insights.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdSet = bizSdk.AdSet; +const AdsInsights = bizSdk.AdsInsights; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'impressions', +]; +params = { + 'breakdown' : 'publisher_platform', +}; +const insightss = (new AdSet(id)).getInsights( + fields, + params +); +logApiCallResult('insightss api call complete.', insightss); \ No newline at end of file diff --git a/examples/ads_insights_edge_ad_group_insights.js b/examples/ads_insights_edge_ad_group_insights.js new file mode 100644 index 00000000..202f3748 --- /dev/null +++ b/examples/ads_insights_edge_ad_group_insights.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Ad = bizSdk.Ad; +const AdsInsights = bizSdk.AdsInsights; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'impressions', +]; +params = { + 'date_preset' : 'last_7d', +}; +const insightss = (new Ad(id)).getInsights( + fields, + params +); +logApiCallResult('insightss api call complete.', insightss); \ No newline at end of file diff --git a/examples/ads_insights_edge_campaign_group_ad_level_insights.js b/examples/ads_insights_edge_campaign_group_ad_level_insights.js new file mode 100644 index 00000000..b43ff3ab --- /dev/null +++ b/examples/ads_insights_edge_campaign_group_ad_level_insights.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; +const AdsInsights = bizSdk.AdsInsights; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'impressions', + 'ad_id', +]; +params = { + 'level' : 'ad', +}; +const insightss = (new Campaign(id)).getInsights( + fields, + params +); +logApiCallResult('insightss api call complete.', insightss); \ No newline at end of file diff --git a/examples/ads_insights_edge_campaign_group_insights.js b/examples/ads_insights_edge_campaign_group_insights.js new file mode 100644 index 00000000..e7280ca4 --- /dev/null +++ b/examples/ads_insights_edge_campaign_group_insights.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; +const AdsInsights = bizSdk.AdsInsights; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'impressions', +]; +params = { + 'date_preset' : 'last_3d', +}; +const insightss = (new Campaign(id)).getInsights( + fields, + params +); +logApiCallResult('insightss api call complete.', insightss); \ No newline at end of file diff --git a/examples/ads_pixel_events_post.js b/examples/ads_pixel_events_post.js new file mode 100644 index 00000000..8edcd8f2 --- /dev/null +++ b/examples/ads_pixel_events_post.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdsPixel = bizSdk.AdsPixel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'data' : [{'event_name':'PageView','event_time':1721461428,'user_data':{'fbc':'fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890','fbp':'fb.1.1558571054389.1098115397','em':'309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd'}}], +}; +const events = (new AdsPixel(id)).createEvent( + fields, + params +); +logApiCallResult('events api call complete.', events); \ No newline at end of file diff --git a/examples/ads_pixel_events_post_custom.js b/examples/ads_pixel_events_post_custom.js new file mode 100644 index 00000000..87b87c69 --- /dev/null +++ b/examples/ads_pixel_events_post_custom.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Content = bizSdk.Content; +const CustomData = bizSdk.CustomData; +const DeliveryCategory = bizSdk.DeliveryCategory; +const EventRequest = bizSdk.EventRequest; +const UserData = bizSdk.UserData; +const ServerEvent = bizSdk.ServerEvent; + +const access_token = ''; +const pixel_id = ''; +const api = bizSdk.FacebookAdsApi.init(access_token); + +let current_timestamp = Math.floor(new Date() / 1000); + +const userData = (new UserData()) + .setEmails(['joe@eg.com']) + .setPhones(['12345678901', '14251234567']) + // It is recommended to send Client IP and User Agent for Conversions API Events. + .setClientIpAddress(request.connection.remoteAddress) + .setClientUserAgent(request.headers['user-agent']) + .setFbp('fb.1.1558571054389.1098115397') + .setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890'); + +const content = (new Content()) + .setId('product123') + .setQuantity(1) + .setDeliveryCategory(DeliveryCategory.HOME_DELIVERY); + +const customData = (new CustomData()) + .setContents([content]) + .setCurrency('usd') + .setValue(123.45); + +const serverEvent = (new ServerEvent()) + .setEventName('Purchase') + .setEventTime(current_timestamp) + .setUserData(userData) + .setCustomData(customData) + .setEventSourceUrl('http://jaspers-market.com/product/123') + .setActionSource('website'); + +const eventsData = [serverEvent]; +const eventRequest = (new EventRequest(access_token, pixel_id)) + .setEvents(eventsData); + +eventRequest.execute().then( + response => { + console.log('Response: ', response); + }, + err => { + console.error('Error: ', err); + } +); \ No newline at end of file diff --git a/examples/ads_pixel_shared_accounts_edge.js b/examples/ads_pixel_shared_accounts_edge.js new file mode 100644 index 00000000..f440f1a3 --- /dev/null +++ b/examples/ads_pixel_shared_accounts_edge.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdsPixel = bizSdk.AdsPixel; +const AdAccount = bizSdk.AdAccount; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'business' : '', +}; +const shared_accountss = (new AdsPixel(id)).getSharedAccounts( + fields, + params +); +logApiCallResult('shared_accountss api call complete.', shared_accountss); \ No newline at end of file diff --git a/examples/ads_pixel_shared_accounts_post.js b/examples/ads_pixel_shared_accounts_post.js new file mode 100644 index 00000000..913c8209 --- /dev/null +++ b/examples/ads_pixel_shared_accounts_post.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdsPixel = bizSdk.AdsPixel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'account_id' : '', + 'business' : '', +}; +const shared_accounts = (new AdsPixel(id)).createSharedAccount( + fields, + params +); +logApiCallResult('shared_accounts api call complete.', shared_accounts); \ No newline at end of file diff --git a/examples/ads_pixel_shared_agencies_edge.js b/examples/ads_pixel_shared_agencies_edge.js new file mode 100644 index 00000000..fa0a4a79 --- /dev/null +++ b/examples/ads_pixel_shared_agencies_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdsPixel = bizSdk.AdsPixel; +const Business = bizSdk.Business; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const shared_agenciess = (new AdsPixel(id)).getSharedAgencies( + fields, + params +); +logApiCallResult('shared_agenciess api call complete.', shared_agenciess); \ No newline at end of file diff --git a/examples/campaigns_delete.js b/examples/campaigns_delete.js new file mode 100644 index 00000000..0ce5d4cf --- /dev/null +++ b/examples/campaigns_delete.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Campaign = bizSdk.Campaign; +const AbstractObject = bizSdk.AbstractObject; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new Campaign(id)).delete( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/custom_audience_delete.js b/examples/custom_audience_delete.js new file mode 100644 index 00000000..55003ff9 --- /dev/null +++ b/examples/custom_audience_delete.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; +const AbstractObject = bizSdk.AbstractObject; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new CustomAudience(id)).delete( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/custom_audience_node.js b/examples/custom_audience_node.js new file mode 100644 index 00000000..9faf0e53 --- /dev/null +++ b/examples/custom_audience_node.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new CustomAudience(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/custom_audience_node_read_rule.js b/examples/custom_audience_node_read_rule.js new file mode 100644 index 00000000..f0e221e9 --- /dev/null +++ b/examples/custom_audience_node_read_rule.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'name', + 'rule', +]; +params = { +}; +const sample_code = (new CustomAudience(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/custom_audience_post.js b/examples/custom_audience_post.js new file mode 100644 index 00000000..8277926c --- /dev/null +++ b/examples/custom_audience_post.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Updated Name for CA', +}; +const sample_code = (new CustomAudience(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/custom_audience_users_post.js b/examples/custom_audience_users_post.js new file mode 100644 index 00000000..88cbf5bc --- /dev/null +++ b/examples/custom_audience_users_post.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'payload' : {'schema':['EMAIL','LOOKALIKE_VALUE'],'data':[['9b431636bd164765d63c573c346708846af4f68fe3701a77a3bdd7e7e5166254',44.5],['8cc62c145cd0c6dc444168eaeb1b61b351f9b1809a579cc9b4c9e9d7213a39ee',140],['4eaf70b1f7a797962b9d2a533f122c8039012b31e0a52b34a426729319cb792a',0],['98df8d46f118f8bef552b0ec0a3d729466a912577830212a844b73960777ac56',0.9]]}, +}; +const users = (new CustomAudience(id)).createUser( + fields, + params +); +logApiCallResult('users api call complete.', users); \ No newline at end of file diff --git a/examples/custom_audience_users_post_cross_platform.js b/examples/custom_audience_users_post_cross_platform.js new file mode 100644 index 00000000..f784076b --- /dev/null +++ b/examples/custom_audience_users_post_cross_platform.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 CustomAudience = bizSdk.CustomAudience; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'payload' : {'schema':['EMAIL','MADID','APPUID','LOOKALIKE_VALUE'],'app_ids':[''],'data':[['b36a83701f1c3191e19722d6f90274bc1b5501fe69ebf33313e440fe4b0fe210','6032d997-3ab0-4de0-aa16-8af0e5b482fb','1234567890','0.9'],['2b3b2b9ce842ab8b6a6c614cb1f9604bb8a0d502d1af49c526b72b10894e95b5','B67385F8-9A82-4670-8C0A-6F9EA7513F5F','','0'],['898628e28890f937bdf009391def42879c401a4bcf1b5fd24e738d9f5da8cbbb','','9876543210','0.4']]}, +}; +const users = (new CustomAudience(id)).createUser( + fields, + params +); +logApiCallResult('users api call complete.', users); \ No newline at end of file diff --git a/examples/m_u_l_t_i_post.js b/examples/m_u_l_t_i_post.js new file mode 100644 index 00000000..c157946c --- /dev/null +++ b/examples/m_u_l_t_i_post.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdLabel = bizSdk.AdLabel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Label 1', +}; +const adlabels = (new AdAccount(id)).createAdLabel( + fields, + params +); +logApiCallResult('adlabels api call complete.', adlabels); + +fields = [ +]; +params = { + 'name' : 'My Label 2', +}; +const adlabels = (new AdAccount(id)).createAdLabel( + fields, + params +); +logApiCallResult('adlabels api call complete.', adlabels); \ No newline at end of file diff --git a/examples/m_u_l_t_i_post_one.js b/examples/m_u_l_t_i_post_one.js new file mode 100644 index 00000000..47eae7a4 --- /dev/null +++ b/examples/m_u_l_t_i_post_one.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdLabel = bizSdk.AdLabel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Label 1', +}; +const adlabels = (new AdAccount(id)).createAdLabel( + fields, + params +); +logApiCallResult('adlabels api call complete.', adlabels); \ No newline at end of file diff --git a/examples/m_u_l_t_i_post_two.js b/examples/m_u_l_t_i_post_two.js new file mode 100644 index 00000000..2b1261e4 --- /dev/null +++ b/examples/m_u_l_t_i_post_two.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdLabel = bizSdk.AdLabel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 Label 2', +}; +const adlabels = (new AdAccount(id)).createAdLabel( + fields, + params +); +logApiCallResult('adlabels api call complete.', adlabels); \ No newline at end of file diff --git a/examples/offline_conversions_create_offline_set.js b/examples/offline_conversions_create_offline_set.js new file mode 100644 index 00000000..62f0184c --- /dev/null +++ b/examples/offline_conversions_create_offline_set.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Business = bizSdk.Business; +const OfflineConversionDataSet = bizSdk.OfflineConversionDataSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'offline_event_set', + 'description' : 'conversion data used for superbowl campaign', +}; +const offline_conversion_data_sets = (new Business(id)).createOfflineConversionDataSet( + fields, + params +); +logApiCallResult('offline_conversion_data_sets api call complete.', offline_conversion_data_sets); \ No newline at end of file diff --git a/examples/page_feed_edge.js b/examples/page_feed_edge.js new file mode 100644 index 00000000..92d5bbfb --- /dev/null +++ b/examples/page_feed_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const PagePost = bizSdk.PagePost; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const feeds = (new Page(id)).getFeed( + fields, + params +); +logApiCallResult('feeds api call complete.', feeds); \ No newline at end of file diff --git a/examples/page_feed_post.js b/examples/page_feed_post.js new file mode 100644 index 00000000..572edeca --- /dev/null +++ b/examples/page_feed_post.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const PagePost = bizSdk.PagePost; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'message' : 'This is a test value', +}; +const feed = (new Page(id)).createFeed( + fields, + params +); +logApiCallResult('feed api call complete.', feed); \ No newline at end of file diff --git a/examples/page_feed_post_feed_image_deep_link.js b/examples/page_feed_post_feed_image_deep_link.js new file mode 100644 index 00000000..202fe9de --- /dev/null +++ b/examples/page_feed_post_feed_image_deep_link.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const PagePost = bizSdk.PagePost; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'message' : 'This is a test message', + 'call_to_action' : {'type':'BUY_NOW','value':{'link':'','app_link':''}}, +}; +const feed = (new Page(id)).createFeed( + fields, + params +); +logApiCallResult('feed api call complete.', feed); \ No newline at end of file diff --git a/examples/page_node.js b/examples/page_node.js new file mode 100644 index 00000000..53fdd5ce --- /dev/null +++ b/examples/page_node.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = [ + 'location{latitude', + 'longitude}', + 'is_permanently_closed', +]; +params = { + 'limit' : '30000', +}; +const locationss = (new Page(id)).getLocations( + fields, + params +); +logApiCallResult('locationss api call complete.', locationss); \ No newline at end of file diff --git a/examples/page_node_page_search.js b/examples/page_node_page_search.js new file mode 100644 index 00000000..248215cb --- /dev/null +++ b/examples/page_node_page_search.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'type' : 'adradiussuggestion', + 'latitude' : '51.5152253', + 'longitude' : '-0.1423029', +}; +const sample_code = (new Page(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/page_photos_edge.js b/examples/page_photos_edge.js new file mode 100644 index 00000000..d4023db2 --- /dev/null +++ b/examples/page_photos_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const Photo = bizSdk.Photo; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const photoss = (new Page(id)).getPhotos( + fields, + params +); +logApiCallResult('photoss api call complete.', photoss); \ No newline at end of file diff --git a/examples/page_photos_post.js b/examples/page_photos_post.js new file mode 100644 index 00000000..aa57a590 --- /dev/null +++ b/examples/page_photos_post.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const Photo = bizSdk.Photo; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'url' : 'https://www.facebook.com/images/fb_icon_325x325.png', + 'published' : 'false', +}; +const photos = (new Page(id)).createPhoto( + fields, + params +); +logApiCallResult('photos api call complete.', photos); \ No newline at end of file diff --git a/examples/page_picture_edge.js b/examples/page_picture_edge.js new file mode 100644 index 00000000..e768c837 --- /dev/null +++ b/examples/page_picture_edge.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const ProfilePictureSource = bizSdk.ProfilePictureSource; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'redirect' : '0', +}; +const pictures = (new Page(id)).getPicture( + fields, + params +); +logApiCallResult('pictures api call complete.', pictures); \ No newline at end of file diff --git a/examples/page_post_comments_post.js b/examples/page_post_comments_post.js new file mode 100644 index 00000000..c36018bc --- /dev/null +++ b/examples/page_post_comments_post.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 PagePost = bizSdk.PagePost; +const Comment = bizSdk.Comment; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'message' : 'This is a test value', +}; +const comments = (new PagePost(id)).createComment( + fields, + params +); +logApiCallResult('comments api call complete.', comments); \ No newline at end of file diff --git a/examples/page_post_delete.js b/examples/page_post_delete.js new file mode 100644 index 00000000..01129cce --- /dev/null +++ b/examples/page_post_delete.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 PagePost = bizSdk.PagePost; +const AbstractObject = bizSdk.AbstractObject; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new PagePost(id)).delete( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/page_post_node.js b/examples/page_post_node.js new file mode 100644 index 00000000..29f909ae --- /dev/null +++ b/examples/page_post_node.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 PagePost = bizSdk.PagePost; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new PagePost(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/page_post_post.js b/examples/page_post_post.js new file mode 100644 index 00000000..102c960d --- /dev/null +++ b/examples/page_post_post.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 PagePost = bizSdk.PagePost; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'message' : 'This is a test value', +}; +const sample_code = (new PagePost(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/page_posts_edge.js b/examples/page_posts_edge.js new file mode 100644 index 00000000..ab20ba9e --- /dev/null +++ b/examples/page_posts_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const PagePost = bizSdk.PagePost; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const postss = (new Page(id)).getPosts( + fields, + params +); +logApiCallResult('postss api call complete.', postss); \ No newline at end of file diff --git a/examples/page_posts_edge_page_post_create_carousel.js b/examples/page_posts_edge_page_post_create_carousel.js new file mode 100644 index 00000000..f242eb79 --- /dev/null +++ b/examples/page_posts_edge_page_post_create_carousel.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const PagePost = bizSdk.PagePost; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'message' : 'Browse our latest products', + 'published' : '0', + 'child_attachments' : [{'link':'','name':'Product 1','description':'$4.99','image_hash':''},{'link':'','name':'Product 2','description':'$4.99','image_hash':''},{'link':'','name':'Product 3','description':'$4.99','image_hash':''},{'link':'','name':'Product 4','description':'$4.99','image_hash':''}], + 'caption' : 'WWW.EXAMPLE.COM', + 'link' : 'http://www.example.com/products', +}; +const postss = (new Page(id)).getPosts( + fields, + params +); +logApiCallResult('postss api call complete.', postss); \ No newline at end of file diff --git a/examples/page_roles_edge.js b/examples/page_roles_edge.js new file mode 100644 index 00000000..46667744 --- /dev/null +++ b/examples/page_roles_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; +const User = bizSdk.User; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const roless = (new Page(id)).getRoles( + fields, + params +); +logApiCallResult('roless api call complete.', roless); \ No newline at end of file diff --git a/examples/page_subscribed_apps_post.js b/examples/page_subscribed_apps_post.js new file mode 100644 index 00000000..f18b2ee5 --- /dev/null +++ b/examples/page_subscribed_apps_post.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Page = bizSdk.Page; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'subscribed_fields' : 'leadgen', +}; +const subscribed_apps = (new Page(id)).createSubscribedApp( + fields, + params +); +logApiCallResult('subscribed_apps api call complete.', subscribed_apps); \ No newline at end of file diff --git a/examples/product_catalog_event_stats_edge.js b/examples/product_catalog_event_stats_edge.js new file mode 100644 index 00000000..7920da4d --- /dev/null +++ b/examples/product_catalog_event_stats_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 ProductCatalog = bizSdk.ProductCatalog; +const ProductEventStat = bizSdk.ProductEventStat; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const event_statss = (new ProductCatalog(id)).getEventStats( + fields, + params +); +logApiCallResult('event_statss api call complete.', event_statss); \ No newline at end of file diff --git a/examples/product_catalog_hotels_post.js b/examples/product_catalog_hotels_post.js new file mode 100644 index 00000000..23ddde38 --- /dev/null +++ b/examples/product_catalog_hotels_post.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 ProductCatalog = bizSdk.ProductCatalog; +const Hotel = bizSdk.Hotel; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { + 'hotel_id' : 'h_1', + 'name' : 'Sample Hotel', + 'description' : 'hotel description', + 'brand' : 'hotel brand', + 'url' : 'http://www.example.com/samplehotel', + 'images' : [{'image_url':'https://www.example.com/pic1.jpg','tags':['front view','balcony']},{'image_url':'http://www.example.com/pic2.jpg','tags':['lobby view']}], + 'address' : {'street_address':'1 Hacker Way','city':'Menlo Park','region':'California','country':'United States','postal_code':'94025','neighborhoods':['Palo Alto','Menlo Park'],'latitude':37.484116,'longitude':-122.148244}, + 'guest_ratings' : [{'score':7.8,'max_score':10,'rating_system':'sample_rating','number_of_raters':780}], + 'star_rating' : '4', + 'phone' : '+351234123456', +}; +const hotels = (new ProductCatalog(id)).createHotel( + fields, + params +); +logApiCallResult('hotels api call complete.', hotels); \ No newline at end of file diff --git a/examples/product_catalog_hotels_post_update_hotels_catalog_settings.js b/examples/product_catalog_hotels_post_update_hotels_catalog_settings.js new file mode 100644 index 00000000..6371933b --- /dev/null +++ b/examples/product_catalog_hotels_post_update_hotels_catalog_settings.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 ProductCatalog = bizSdk.ProductCatalog; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new ProductCatalog(id)).update( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/product_catalog_product_feeds_post_product_feed.js b/examples/product_catalog_product_feeds_post_product_feed.js new file mode 100644 index 00000000..363a2c22 --- /dev/null +++ b/examples/product_catalog_product_feeds_post_product_feed.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 ProductCatalog = bizSdk.ProductCatalog; +const ProductFeed = bizSdk.ProductFeed; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Test Feed', + 'schedule' : {'interval':'DAILY','url':'http://www.example.com/sample_feed.tsv','hour':'22'}, +}; +const product_feeds = (new ProductCatalog(id)).createProductFeed( + fields, + params +); +logApiCallResult('product_feeds api call complete.', product_feeds); \ No newline at end of file diff --git a/examples/product_catalog_product_sets_post_hotel_set.js b/examples/product_catalog_product_sets_post_hotel_set.js new file mode 100644 index 00000000..cb2200a0 --- /dev/null +++ b/examples/product_catalog_product_sets_post_hotel_set.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 ProductCatalog = bizSdk.ProductCatalog; +const ProductSet = bizSdk.ProductSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Test Hotel Set', + 'filter' : {'brand':{'i_contains':'sample brand'}}, +}; +const product_sets = (new ProductCatalog(id)).createProductSet( + fields, + params +); +logApiCallResult('product_sets api call complete.', product_sets); \ No newline at end of file diff --git a/examples/product_catalog_product_sets_post_product_set.js b/examples/product_catalog_product_sets_post_product_set.js new file mode 100644 index 00000000..0f024058 --- /dev/null +++ b/examples/product_catalog_product_sets_post_product_set.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 ProductCatalog = bizSdk.ProductCatalog; +const ProductSet = bizSdk.ProductSet; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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' : 'Test Set', + 'filter' : {'product_type':{'i_contains':'shirt'}}, +}; +const product_sets = (new ProductCatalog(id)).createProductSet( + fields, + params +); +logApiCallResult('product_sets api call complete.', product_sets); \ No newline at end of file diff --git a/examples/user_accounts_edge.js b/examples/user_accounts_edge.js new file mode 100644 index 00000000..84aab404 --- /dev/null +++ b/examples/user_accounts_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 User = bizSdk.User; +const Page = bizSdk.Page; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const accountss = (new User(id)).getAccounts( + fields, + params +); +logApiCallResult('accountss api call complete.', accountss); \ No newline at end of file diff --git a/examples/user_ad_accounts_edge.js b/examples/user_ad_accounts_edge.js new file mode 100644 index 00000000..8d6a8840 --- /dev/null +++ b/examples/user_ad_accounts_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 User = bizSdk.User; +const AdAccount = bizSdk.AdAccount; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const adaccountss = (new User(id)).getAdAccounts( + fields, + params +); +logApiCallResult('adaccountss api call complete.', adaccountss); \ No newline at end of file diff --git a/examples/user_lead_gen_info_node.js b/examples/user_lead_gen_info_node.js new file mode 100644 index 00000000..b2dee2a8 --- /dev/null +++ b/examples/user_lead_gen_info_node.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 Lead = bizSdk.Lead; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new Lead(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/user_node.js b/examples/user_node.js new file mode 100644 index 00000000..3969509f --- /dev/null +++ b/examples/user_node.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 User = bizSdk.User; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const sample_code = (new User(id)).get( + fields, + params +); +logApiCallResult('sample_code api call complete.', sample_code); \ No newline at end of file diff --git a/examples/video_thumbnails_edge.js b/examples/video_thumbnails_edge.js new file mode 100644 index 00000000..8a4c35f5 --- /dev/null +++ b/examples/video_thumbnails_edge.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * 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 AdVideo = bizSdk.AdVideo; +const VideoThumbnail = bizSdk.VideoThumbnail; + +const access_token = ''; +const app_secret = ''; +const app_id = ''; +const 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 = { +}; +const thumbnailss = (new AdVideo(id)).getThumbnails( + fields, + params +); +logApiCallResult('thumbnailss api call complete.', thumbnailss); \ No newline at end of file diff --git a/package.json b/package.json index 1fa15f1a..ccc423af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "facebook-nodejs-business-sdk", - "version": "21.0.3", + "version": "21.0.4", "description": "SDK for the Facebook Marketing API in Javascript and Node.js", "author": "Facebook", "maintainers": [ diff --git a/src/objects/ad-creative-feature-customizations.js b/src/objects/ad-creative-feature-customizations.js index fe222c4b..15c975b5 100644 --- a/src/objects/ad-creative-feature-customizations.js +++ b/src/objects/ad-creative-feature-customizations.js @@ -18,6 +18,7 @@ import {AbstractCrudObject} from './../abstract-crud-object'; export default class AdCreativeFeatureCustomizations extends AbstractCrudObject { static get Fields (): Object { return Object.freeze({ + image_crop_style: 'image_crop_style', showcase_card_display: 'showcase_card_display', }); }