我在 firebase 函数中使用 node.js facebook sdk facebook-nodejs-business-sdk 来使用 custom_locations 更新 Ad Sets 定位参数,并尝试了许多不同的方法来更新它,但都没有奏效。我使用了 API 中的 TargetingGeoLocationCustomLocation 对象,还尝试直接将位置添加为对象。我还尝试将纬度/经度作为字符串、浮点数、parseFloat 字符串发送,但似乎没有任何效果。如果我在没有 custom_locations 的情况下尝试它,它会通过,所以我认为它与 API 的设置没有任何关系。这是我尝试的最后一个代码:
const adsSdk = require('facebook-nodejs-business-sdk');
const targeting = adset.targeting // Pulling a targeting object from the request
const customLoc = adsSdk.TargetingGeoLocationCustomLocation = {
radius: 1,
latitude: parseFloat(37.32798355),
longitude: parseFloat(-73.01982712),
distance_unit: 'mile'
}
const geoLocations = {
location_types: ['recent'],
custom_locations: [
customLoc
]
}
targeting.geo_locations = geoLocations
const accessToken = req.body.fbAuth;
const api = adsSdk.FacebookAdsApi.init(accessToken);
const AdSet = adsSdk.AdSet;
new AdSet(doc.id, {
targeting: targeting
})
.update()
.then( response => console.log('fb response', response) )
.catch( error => console.log('error', error) )
我觉得我已经尝试了一切,并且非常感谢任何建议或建议