Reputation: 33
unsupported post request. Object with ID '320278220447428' 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"
hello, I've been trying to post to my facebook page when i add a product into the website using express... im new to coding with the facebook api so i dont know why does this cause an error ... thank you very much !
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);
}
});
Upvotes: 0
Views: 930
Reputation: 33
you should check the page id in your facebook page and try and send a post request... also theres a page token and a user token which are totally diffrent.
Upvotes: 0