Direct PAGE_ID/feed endpoint update

This commit is contained in:
Hamza-Ayed
2026-07-24 16:51:33 +03:00
parent b47102f36b
commit 0b9dca5d75
2 changed files with 9 additions and 38 deletions
+4 -19
View File
@@ -36,10 +36,9 @@ const message = `شركتك تحمل اسمك… وتطبيقك يحمل اسم
💬 تواصل معنا عبر واتساب: https://wa.me/962798583052`;
async function main() {
console.log('Publishing post to Facebook Page via Page Token...');
// Try direct /me/feed endpoint first (works for Page Access Token)
let res = await fetch(`https://graph.facebook.com/v19.0/me/feed`, {
console.log(`Publishing post directly to Facebook Page ID: ${PAGE_ID}...`);
const res = await fetch(`https://graph.facebook.com/v19.0/${PAGE_ID}/feed`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -48,21 +47,7 @@ async function main() {
})
});
let data = await res.json();
if (data.error && PAGE_ID) {
console.log('Direct /me/feed failed, trying Page ID endpoint:', PAGE_ID);
res = await fetch(`https://graph.facebook.com/v19.0/${PAGE_ID}/feed`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
access_token: USER_TOKEN,
message: message
})
});
data = await res.json();
}
const data = await res.json();
console.log('Response from Meta:', JSON.stringify(data, null, 2));
}