我已使用 https 调用将我的应用程序连接到 Facebook Ad Library API。 它在某些页面上运行良好。但在其他一些页面中,它不会返回所有页面广告,或者在某些页面中,它不会返回任何广告!但当你查看 Facebook 广告库网站中的页面本身时。它正在显示页面广告。 例如,Hunger Games 页面位于 url
https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=ALL&view_all_page_id=159746560708670&search_type=page&media_type=all
,您可以看到它在页面中显示了 20 多个广告,但是当您尝试从广告库 API 获取其广告时。它返回{"data":[]}
。我从 Facebook Library API 获取广告的代码是。
const axios = require('axios');
let config = {
method: 'get',
url: 'https://graph.facebook.com/v18.0/ads_archive?ad_type=ALL&ad_reached_countries=["AD","AE","AG","AI","AL","AM","AO","AQ","AR","AT","AU","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO","BR","BS","BT","BV","BW","BY","BZ","CA","CD","CF","CG","CH","CI","CL","CM","CO","CR","CV","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","ER","ES","ET","FI","FJ","FK","FM","FR","GA","GB","GD","GE","GG","GH","GI","GM","GN","GQ","GR","GS","GT","GW","GY","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MG","MH","MK","ML","MM","MN","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NE","NG","NI","NL","NO","NP","NR","NZ","OM","PA","PE","PG","PH","PK","PL","PN","PS","PT","PW","PY","QA","RO","RS","RW","SA","SB","SC","SE","SG","SH","SI","SK","SL","SM","SN","SO","SR","SS","ST","SV","SZ","TC","TD","TG","TH","TJ","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","US","UY","UZ","VA","VC","VE","VG","VN","VU","WS","XK","YE","ZA","ZM","ZW"]&access_token=ACCESS_TOKEN&ad_active_status=ALL&media_type=ALL&search_page_ids=159746560708670'
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
我还注意到,当我通过
ALL
而不是所有到达的国家/地区的数组时
ad_reached_countries
参数。它不会返回任何广告,我必须将所有可能的国家/地区放入该值中。我已经尝试了很多方法来解决这个问题,但它不起作用。
我还尝试过 FB Graph Explorer 及其 Radlibrary 或其 Ad Library API 脚本存储库,但它们都没有返回预期结果。
有什么办法可以解决这个问题吗?
我可以确认这似乎是一个错误: https://ambience.sk/facebook-ads-library-api-ad_reached_countries-parameter-does-not-support-all-enum/
尽管文档声称如此,但使用 ALL 或 ['ALL'] 而不是具有多个国家/地区的数组似乎不起作用。只需使用我在解决方案中推荐的内容即可 - 这已经过测试并且效果良好。