1

我正在开发一个应用程序来使用版本 v9.0 中的包“facebook-nodejs-business-sdk”来使用 facebook api。

我正在寻找一种获得兴趣的方法,但我找不到。

我查看了包中可用的示例,但找不到任何可以让我搜索搜索节点的内容。

使用 graph api explorer 我可以看到使用 javascript 进行这些调用的代码如下:

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

但是应用程序正在使用提到的包,并且通常具有特定的调用方法。

我是编程初学者,所以我迷路了。

有人能帮我吗?

谢谢!

4

1 回答 1

0

我在 SDK 中没有找到对此的任何引用,但您似乎可以通过以下示例自己调用目标搜索 api :

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);
});

此代码将输出如下内容:

{
  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'
      ....

希望这有帮助

于 2021-01-09T21:08:10.233 回答