我今天开始使用 Facebook Marketing API。我只是想从我的 Facebook 业务帐户中读取广告系列。我有一个广告帐户和一个在那里创建的广告系列。我想我的问题是生成令牌。
我只是从这里生成令牌:https ://developers.facebook.com/tools/explorer?classic=0
我得到的错误是:
{ error:
{ message: 'Unsupported get request. Object with ID \'10xxxxxxxx\' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api',
type: 'GraphMethodException',
code: 100,
error_subcode: 33,
fbtrace_id: 'E5CAU6UvHwF' } }
我的 Node.js 代码是:
const readCampaign = async (program) => {
const accessToken = TOKEN
const api = adsSdk.FacebookAdsApi.init(accessToken)
const account = new AdAccount('act_' + program.accountid)
console.log('act_' + account.id) // fields can be accessed as properties
let result
account.read([AdAccount.Fields.name])
.then((account) => {
return account.getCampaigns([Campaign.Fields.name], { limit: 10 }) // fields array and params
})
.then((result) => {
campaigns = result
campaigns.forEach((campaign) => console.log(campaign.name))
}).catch(console.error);
console.log(result)
}
要生成令牌,我选择我创建的应用程序“获取用户访问令牌”,然后在那里选择所有可能的权限 - 只是为了测试这一点。
我究竟做错了什么?谢谢