1

I am developing an application to consume the facebook api using the package "facebook-nodejs-business-sdk" in version v9.0.

I'm looking for a method to get interests, but I can't find it.

I looked in the examples available in the package, but I can't find anything that allows me to search the search node.

Using the graph api explorer I can see that the code to make these calls with javascript is as follows:

FB.api( '/search','GET', {"type":"adinterest","q":"Golf","limit":"10000","locale":"pt_BR"}, function(response) { // Insert your code here } );

But the application is using the mentioned package and generally has specific methods for calls.

I'm a beginner in programming so I'm lost.

Can someone help me?

Thanks!

Matteo
  • 37,680
  • 11
  • 100
  • 115

1 Answers1

0

I didn't find any reference to this in the SDK but seems you could call the targeting search api by yourself with the following example:

const bizSdk = require('facebook-nodejs-business-sdk');

const access_token = '<the_token>';

const api = bizSdk.FacebookAdsApi.init(access_token);
const showDebugingInfo = true; // Setting this to true shows more debugging info.
if (showDebugingInfo) {
  api.setDebug(true);
}

const params = {
  'type' : 'adinterest',
  'q' : 'Golf',
  'limit' : '10000',
  'locale' : 'pt_BR',
};

api.call('GET',['search'], params).then((response) => {
  console.log(response)
}).catch(error => {
  console.log("something bad happened somewhere", error);
});

This code will output something like:

{
  data: [
    {
      id: '6003631859287',
      name: 'Golf',
      audience_size: 218921,
      path: [Array],
      description: null,
      disambiguation_category: 'Negócio local',
      topic: 'News and entertainment'
    },
    {
      id: '6003510075864',
      name: 'Golfe',
      audience_size: 310545288,
      path: [Array],
      description: '',
      topic: 'Sports and outdoors'
      ....

Hope this help

Matteo
  • 37,680
  • 11
  • 100
  • 115