mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Improve how posts are published and scheduled to Facebook
Refactor FacebookService to correctly pass parameters via URL query strings for POST requests instead of request bodies in publishTextPost, publishPhotoPost, scheduleTextPost, and schedulePhotoPost methods. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/c9jWr93
This commit is contained in:
1 parent
daadd46e8b
commit
82b73620dd
2 files changed
+12
-12
No files matched your search
@@ -18,6 +18,10 @@ externalPort = 80
|
||||
localPort = 5555
|
||||
externalPort = 3002
|
||||
|
||||
[[ports]]
|
||||
localPort = 40011
|
||||
externalPort = 3003
|
||||
|
||||
[[ports]]
|
||||
localPort = 40537
|
||||
externalPort = 3000
|
||||
|
||||
@@ -39,16 +39,15 @@ export class FacebookService {
|
||||
}
|
||||
|
||||
private async publishTextPost(post: Post, page: SocialPage): Promise<string> {
|
||||
const url = `${this.baseUrl}/${page.pageId}/feed`;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
access_token: page.accessToken!,
|
||||
message: post.content,
|
||||
});
|
||||
|
||||
const url = `${this.baseUrl}/${page.pageId}/feed?${params.toString()}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: params,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -61,8 +60,6 @@ export class FacebookService {
|
||||
}
|
||||
|
||||
private async publishPhotoPost(post: Post, page: SocialPage, media: Media): Promise<string> {
|
||||
const url = `${this.baseUrl}/${page.pageId}/photos`;
|
||||
|
||||
// Use the Facebook Feed optimized URL (1200x630)
|
||||
const photoUrl = media.facebookFeedUrl || media.originalUrl;
|
||||
|
||||
@@ -72,9 +69,10 @@ export class FacebookService {
|
||||
url: photoUrl,
|
||||
});
|
||||
|
||||
const url = `${this.baseUrl}/${page.pageId}/photos?${params.toString()}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: params,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -120,8 +118,6 @@ export class FacebookService {
|
||||
}
|
||||
|
||||
private async scheduleTextPost(post: Post, page: SocialPage, scheduledTimestamp: number): Promise<string> {
|
||||
const url = `${this.baseUrl}/${page.pageId}/feed`;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
access_token: page.accessToken!,
|
||||
message: post.content,
|
||||
@@ -129,9 +125,10 @@ export class FacebookService {
|
||||
scheduled_publish_time: scheduledTimestamp.toString(),
|
||||
});
|
||||
|
||||
const url = `${this.baseUrl}/${page.pageId}/feed?${params.toString()}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: params,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -144,8 +141,6 @@ export class FacebookService {
|
||||
}
|
||||
|
||||
private async schedulePhotoPost(post: Post, page: SocialPage, scheduledTimestamp: number, media: Media): Promise<string> {
|
||||
const url = `${this.baseUrl}/${page.pageId}/photos`;
|
||||
|
||||
const photoUrl = media.facebookFeedUrl || media.originalUrl;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
@@ -156,9 +151,10 @@ export class FacebookService {
|
||||
scheduled_publish_time: scheduledTimestamp.toString(),
|
||||
});
|
||||
|
||||
const url = `${this.baseUrl}/${page.pageId}/photos?${params.toString()}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: params,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in new issue
Block a user