不支持发布请求。 ID 为“320278220447428”的对象不 存在,由于缺少权限而无法加载,或者不存在 支持这个操作。请阅读 Graph API 文档: https://developers.facebook.com/docs/graph-api”
你好,当我使用 Express 将产品添加到网站中时,我一直在尝试发布到我的 facebook 页面...我是使用 facebook api 进行编码的新手,所以我不知道为什么这会导致错误...谢谢非常喜欢!
app.post("/products/r", async (req, res) => { // saves the new product from the admin console
const newProduct = new Product(req.body);
await newProduct.save();
const productName = newProduct.name;
const postMessage = `שלום חברים נוסף לאתר מוצר חדש בשם : `;
const apiEndpoint = `https://graph.facebook.com/${pageId}/feed`;
try {
const response = await axios.post(apiEndpoint, {
message: postMessage,
access_token: accessToken,
});
if (response.status === 200) {
const json = { message: 'Posted to Facebook successfully' };
res.status(200).json(json);
} else {
const json = { error: response.data };
res.status(response.status).json(json);
}
} catch (error) {
console.error('Error posting to Facebook:', error.response.data);
const json = { error: 'An error occurred while posting to Facebook' };
res.status(500).json(json);
}
});
您应该检查您的 Facebook 页面中的页面 ID 并尝试发送帖子请求... 还有一个页面令牌和一个用户令牌,它们是完全不同的。