2

我在这里找到了一些通过 Facebooks api 进行目标搜索的不错的文档:

https://developers.facebook.com/docs/marketing-api/targeting-search/

我一直使用成功的代码,是直接从上面的文档中复制过来的,如下:

(当然,这是在我使用 Facebook API 设置身份验证之后。)

params = {
    'q': 'baseball',
    'type': 'adinterest',
}

resp = TargetingSearch.search(params=params)
print(resp) 

这很好用,并返回与棒球有关的主题列表,以及有关这些主题的信息,例如观众人数。

现在我真正想做的是执行更复杂的查询,如下所示:

return to me info on the audience of people who are in Santa Monica and who have an interest in baseball.

我想这样做是因为我希望能够查看该组的受众规模,但似乎无法找到有关如何执行此操作或什至可能的文档或示例。

我会想象这样的事情:

params = {
    'q': 'baseball, santa_monica',
    'type': 'adinterest, adlocation',
}

resp = TargetingSearch.search(params=params)
print(resp)

但以上不起作用。

非常感谢任何提示。

4

1 回答 1

1

您正在寻找的 API 称为Reachestimate。您可以使用您拥有的目标来调用它,并将返回预期的数据。

例如,使用作为目标规范:

{
    "publisher_platforms": ["facebook"],
    "facebook_positions": ["feed", "right_hand_column"],
    "device_platforms": ["mobile", "desktop"],
    "geo_locations": {
        "countries": [],
        "custom_locations": [],
        "zips": [],
        "cities": [{
            "key": "2421905"
        }],
        "regions": [],
        "country_groups": [],
        "geo_markets": []
    },
    "excluded_geo_locations": {
        "countries": [],
        "custom_locations": [],
        "zips": [],
        "cities": [],
        "regions": [],
        "country_groups": [],
        "geo_markets": []
    },
    "genders": [1, 2],
    "age_min": 18,
    "age_max": 65,
    "relationship_statuses": [],
    "connections": [],
    "excluded_connections": [],
    "friends_of_connections": [],
    "interests": [{
        "id": "6003087413192",
        "name": "Baseball"
    }]
}

以下 API 调用:

curl -i -X GET \
 "https://graph.facebook.com/v3.2/act_XXX/reachestimate?targeting_spec=%7B%22publisher_platforms%22%3A%5B%22facebook%22%5D%2C%22facebook_positions%22%3A%5B%22feed%22%2C%22right_hand_column%22%5D%2C%22device_platforms%22%3A%5B%22mobile%22%2C%22desktop%22%5D%2C%22geo_locations%22%3A%7B%22countries%22%3A%5B%5D%2C%22custom_locations%22%3A%5B%5D%2C%22zips%22%3A%5B%5D%2C%22cities%22%3A%5B%7B%22key%22%3A%222421905%22%7D%5D%2C%22regions%22%3A%5B%5D%2C%22country_groups%22%3A%5B%5D%2C%22geo_markets%22%3A%5B%5D%7D%2C%22excluded_geo_locations%22%3A%7B%22countries%22%3A%5B%5D%2C%22custom_locations%22%3A%5B%5D%2C%22zips%22%3A%5B%5D%2C%22cities%22%3A%5B%5D%2C%22regions%22%3A%5B%5D%2C%22country_groups%22%3A%5B%5D%2C%22geo_markets%22%3A%5B%5D%7D%2C%22genders%22%3A%5B1%2C2%5D%2C%22age_min%22%3A18%2C%22age_max%22%3A65%2C%22relationship_statuses%22%3A%5B%5D%2C%22connections%22%3A%5B%5D%2C%22excluded_connections%22%3A%5B%5D%2C%22friends_of_connections%22%3A%5B%5D%2C%22interests%22%3A%5B%7B%22id%22%3A%226003087413192%22%2C%22name%22%3A%22Baseball%22%7D%5D%7D&access_token=<user_token>"

将返回:

{
  "data": {
    "users": 12000,
    "estimate_ready": true
  }
}

希望这有帮助

于 2018-12-03T10:21:35.440 回答