我是facebook营销API的新手 . 我能够制作一个广告系列 .
但似乎我无法创建Adset .
我尝试使用Javascript发布到Adset:https://graph.facebook.com/v2.8/act_156221465583672/adsets
有效负载:
var targeting = {
"age_max": 43,
"age_min": 18,
"geo_locations": { "countries": ["US"] }
};
var campaignId = "520337003094784508";
var promotedObject = {
'application_id': 2242592062246511
};
并邮寄身体:
{
"access_token": accessToken,
"name": "testNirAd",
"lifetime_budget": "8000",
"autobid": "true",
"start_time": new Date("October 13, 2017 00:00:00"),
"end_time": new Date("November 13, 2017 00:00:00"),
"optimization_goal": "POST_ENGAGEMENT",
"billing_event": "IMPRESSIONS",
"daily_budget": "2000",
"campaign_id": campaignId,
"targeting": JSON.stringify(targeting),
"status": "PAUSED"
}
But I get this error:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_data": {
"blame_field_specs": [
[
"name"
]
]
},
"error_subcode": 2061015,
"is_transient": false,
"error_user_title": "Required Field Is Missing",
"error_user_msg": "The name field is required. Please complete the
field to continue.",
"fbtrace_id": "HFg4HmwbQhG"
}
}
Which is strange because I have a name field.
然后我尝试了相同的Javascript SDK https://github.com/lucascosta/facebook-js-ads-sdk,使用相同的有效负载数据,这次我得到:{code:1 fbtrace_id:"DcXmP0Wr82Q" message:"An unknown error has occurred." type:"OAuthException"}
请有人帮忙吗?
2 回答
我建议不要在公共论坛上发布访问令牌 . 该错误很可能是格式化问题 .
最简单的调试方法是使用Graph API资源管理器工具,它允许您选择应用程序,生成令牌并定义参数 . 一旦知道语法正确,就可以获得curl代码 . https://developers.facebook.com/tools/explorer/
此外,创建应用广告的代码示例可能会对您有所帮助,尽管它不是JS . https://www.facebookmarketingdevelopers.com/samples/app_install_ad
尝试使用不同的,更少的参数,使用Curl,并得到相同的结果:
得到了:
fbtrace_id:AeI4nngXTmj
顺便说一句,我正在使用沙箱帐户 .
谢谢!