UNPKG

facebook-nodejs-business-sdk

Version:
66 lines (61 loc) 1.85 kB
/** * Copyright (c) 2017-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the license found in the * LICENSE file in the root directory of this source tree. * @flow */ const bizSdk = require('facebook-nodejs-business-sdk'); const process = require('process'); const IGMedia = bizSdk.IGMedia; const IGComment = bizSdk.IGComment; let app_id = '1224202007596125'; let access_token = 'EAARZAZA73LzF0BACZADSZCYwMsLHUTwAAYKm5Tciz5GZCGM8ZAtqoM12q8ybFt6dpElSqbUuXm77dGmZAeK6r1wygAQZCslDqpsVQY6RQA3WhLirP8BcgoKoCTvlyKzkx6xGPZCcRiDXUleDqSbnAQBd5k0ZBhuLf1AB2VsIS5OlYDoTQlOoRuVpmZAiJY9O6d688sZD'; let app_secret = '709348c9665c33a4f988ff3950098131'; let page_access_token_for_ig = 'EAAXpG75bQZBIBACZAtJMLZAp7Ib2ZAOWyocd6MmcZAAkJTOoWRkmWe4dGnbZBXzYchdHFNMln9hMrS2Qp9p4huLYZCSZAT28qKx42CeoErBd8ZCFObHNmLBMvVBGuLNJNMXwIOyPlizurYd1pm1CBnqh4zww2Inf5jMnCpTpfm8ZAPxE0XA78panZBJ'; let ig_post_id = '17903894941090145'; 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; void async function() { try { // _DOC oncall [ellentao] // _DOC open [IG_COMMENT] // _DOC vars [ig_post_id] bizSdk.FacebookAdsApi.init(page_access_token_for_ig); fields = [ ]; params = { }; let ig_comments = await (new IGMedia(ig_post_id)).getComments( fields, params ); let ig_comment_id = ig_comments[0].id; fields = [ ]; params = { }; let ig_comment_repliess = await (new IGComment(ig_comment_id)).getReplies( fields, params ); // _DOC close [IG_COMMENT] } catch(error) { console.log(error); process.exit(1); } }();