将图像附加到页面帖子时,我一直收到此错误消息
message: '(#10) Application does not have permission for this action'
但是仅在发布消息时,它可以正常工作
FB.api('PAGE_ID/feed', 'post', {
message: 'Message is here',
link: 'https://my_LINK.com',
"child_attachments": [
{
"link": "https://1.jpg",
"image_hash": "hash1",
"name": "Some Name",
"description": "Some description"
},
{
"link": "https://2.jpg",
"image_hash": "hash2",
"name": "Some Name",
"description": "Some description 2"
}]
}, function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
});
为了发布到页面,您将需要使用具有publish_pages
权限的页面访问令牌,而该令牌可能会丢失。您可以使用Graph API Explorer tool快速测试请求。您也可以使用Access Token Debugger工具测试您的访问令牌具有哪些权限。另外,请注意,publish_pages
权限为reviewable,需要为approved才能与普通大众一起使用。在批准之前,您只能使用您是管理员的应用程序以及具有管理员角色的页面对其进行测试。
要向Facebook中的帖子添加多张图片,必须按照facebook分两步完成>
上传图片,请参阅this并发表帖子>>
function post_fb_ad(description, ad_images) {
attached_media = []
for (var adImg of ad_images) {
attached_media.push({ media_fbid: adImg.id })
}
FB.api('page_id/feed', 'post', {
message: description,
attached_media: attached_media,
access_token: EXD_ACCESS_TOKEN
}, function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
console.log('post id is ', res)
});
}