Support scripts/.env path
This commit is contained in:
@@ -8,7 +8,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// Auto-load .env file if present
|
// Auto-load .env file if present
|
||||||
const envPath = path.resolve(__dirname, '../.env');
|
const envPath = path.resolve(__dirname, '.env');
|
||||||
if (fs.existsSync(envPath)) {
|
if (fs.existsSync(envPath)) {
|
||||||
const envContent = fs.readFileSync(envPath, 'utf8');
|
const envContent = fs.readFileSync(envPath, 'utf8');
|
||||||
envContent.split('\n').forEach(line => {
|
envContent.split('\n').forEach(line => {
|
||||||
@@ -85,7 +85,7 @@ async function generatePostWithGemini(topic = 'منشور تعريفي عن من
|
|||||||
*/
|
*/
|
||||||
async function publishToFacebook(message) {
|
async function publishToFacebook(message) {
|
||||||
console.log('Publishing generated post to Facebook Page...');
|
console.log('Publishing generated post to Facebook Page...');
|
||||||
|
|
||||||
const url = `https://graph.facebook.com/v19.0/me/feed`;
|
const url = `https://graph.facebook.com/v19.0/me/feed`;
|
||||||
let res = await fetch(url, {
|
let res = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// Auto-load .env file if present
|
// Auto-load .env file if present
|
||||||
const envPath = path.resolve(__dirname, '../.env');
|
const envPath = path.resolve(__dirname, '.env');
|
||||||
if (fs.existsSync(envPath)) {
|
if (fs.existsSync(envPath)) {
|
||||||
const envContent = fs.readFileSync(envPath, 'utf8');
|
const envContent = fs.readFileSync(envPath, 'utf8');
|
||||||
envContent.split('\n').forEach(line => {
|
envContent.split('\n').forEach(line => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// Auto-load .env file if present
|
// Auto-load .env file if present
|
||||||
const envPath = path.resolve(__dirname, '../.env');
|
const envPath = path.resolve(__dirname, '.env');
|
||||||
if (fs.existsSync(envPath)) {
|
if (fs.existsSync(envPath)) {
|
||||||
const envContent = fs.readFileSync(envPath, 'utf8');
|
const envContent = fs.readFileSync(envPath, 'utf8');
|
||||||
envContent.split('\n').forEach(line => {
|
envContent.split('\n').forEach(line => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// Auto-load .env file if present
|
// Auto-load .env file if present
|
||||||
const envPath = path.resolve(__dirname, '../.env');
|
const envPath = path.resolve(__dirname, '.env');
|
||||||
if (fs.existsSync(envPath)) {
|
if (fs.existsSync(envPath)) {
|
||||||
const envContent = fs.readFileSync(envPath, 'utf8');
|
const envContent = fs.readFileSync(envPath, 'utf8');
|
||||||
envContent.split('\n').forEach(line => {
|
envContent.split('\n').forEach(line => {
|
||||||
@@ -37,7 +37,7 @@ const message = `شركتك تحمل اسمك… وتطبيقك يحمل اسم
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log('Publishing post to Facebook Page via Page Token...');
|
console.log('Publishing post to Facebook Page via Page Token...');
|
||||||
|
|
||||||
// Try direct /me/feed endpoint first (works for Page Access Token)
|
// Try direct /me/feed endpoint first (works for Page Access Token)
|
||||||
let res = await fetch(`https://graph.facebook.com/v19.0/me/feed`, {
|
let res = await fetch(`https://graph.facebook.com/v19.0/me/feed`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
Reference in New Issue
Block a user