@memberjunction/actions-bizapps-social 2.111.1 → 2.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -6
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +18 -24
- package/dist/base/base-social.action.js.map +1 -1
- package/dist/providers/buffer/buffer-base.action.d.ts.map +1 -1
- package/dist/providers/buffer/buffer-base.action.js +35 -34
- package/dist/providers/buffer/buffer-base.action.js.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.js +33 -33
- package/dist/providers/facebook/actions/boost-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.js +34 -36
- package/dist/providers/facebook/actions/create-album.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.js +20 -20
- package/dist/providers/facebook/actions/create-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.js +25 -27
- package/dist/providers/facebook/actions/get-page-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.js +19 -23
- package/dist/providers/facebook/actions/get-page-posts.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.js +28 -32
- package/dist/providers/facebook/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.js +42 -44
- package/dist/providers/facebook/actions/respond-to-comments.action.js.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.js +29 -29
- package/dist/providers/facebook/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.js +37 -39
- package/dist/providers/facebook/actions/search-posts.action.js.map +1 -1
- package/dist/providers/facebook/facebook-base.action.d.ts.map +1 -1
- package/dist/providers/facebook/facebook-base.action.js +44 -59
- package/dist/providers/facebook/facebook-base.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js +33 -31
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js +28 -32
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js +19 -19
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.js +24 -26
- package/dist/providers/hootsuite/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js +22 -22
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js +32 -34
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.js +43 -52
- package/dist/providers/hootsuite/actions/search-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js +30 -28
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.js +18 -20
- package/dist/providers/hootsuite/hootsuite-base.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.js +27 -26
- package/dist/providers/instagram/actions/create-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.js +35 -35
- package/dist/providers/instagram/actions/create-story.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.js +38 -59
- package/dist/providers/instagram/actions/get-account-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.js +29 -29
- package/dist/providers/instagram/actions/get-business-posts.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.js +36 -36
- package/dist/providers/instagram/actions/get-comments.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.js +23 -25
- package/dist/providers/instagram/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.js +25 -25
- package/dist/providers/instagram/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.js +56 -60
- package/dist/providers/instagram/actions/search-posts.action.js.map +1 -1
- package/dist/providers/instagram/instagram-base.action.d.ts.map +1 -1
- package/dist/providers/instagram/instagram-base.action.js +25 -27
- package/dist/providers/instagram/instagram-base.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.js +55 -45
- package/dist/providers/linkedin/actions/create-article.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.js +31 -29
- package/dist/providers/linkedin/actions/create-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.js +28 -28
- package/dist/providers/linkedin/actions/get-followers.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.js +20 -20
- package/dist/providers/linkedin/actions/get-organization-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.js +19 -19
- package/dist/providers/linkedin/actions/get-personal-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.js +25 -23
- package/dist/providers/linkedin/actions/get-post-analytics.action.js.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.js +32 -30
- package/dist/providers/linkedin/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.js +28 -30
- package/dist/providers/linkedin/actions/search-posts.action.js.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.d.ts.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.js +33 -38
- package/dist/providers/linkedin/linkedin-base.action.js.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.d.ts.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.js +25 -26
- package/dist/providers/tiktok/tiktok-base.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.js +25 -29
- package/dist/providers/twitter/actions/create-thread.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.js +23 -23
- package/dist/providers/twitter/actions/create-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.js +19 -19
- package/dist/providers/twitter/actions/delete-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.js +40 -47
- package/dist/providers/twitter/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.js +30 -31
- package/dist/providers/twitter/actions/get-mentions.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.js +29 -29
- package/dist/providers/twitter/actions/get-timeline.action.js.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.js +26 -26
- package/dist/providers/twitter/actions/schedule-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.js +56 -58
- package/dist/providers/twitter/actions/search-tweets.action.js.map +1 -1
- package/dist/providers/twitter/twitter-base.action.d.ts.map +1 -1
- package/dist/providers/twitter/twitter-base.action.js +58 -68
- package/dist/providers/twitter/twitter-base.action.js.map +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts.map +1 -1
- package/dist/providers/youtube/youtube-base.action.js +22 -25
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +5 -6
- package/src/base/base-social.action.ts +217 -224
- package/src/providers/buffer/buffer-base.action.ts +435 -441
- package/src/providers/facebook/actions/boost-post.action.ts +350 -386
- package/src/providers/facebook/actions/create-album.action.ts +291 -307
- package/src/providers/facebook/actions/create-post.action.ts +224 -227
- package/src/providers/facebook/actions/get-page-insights.action.ts +383 -403
- package/src/providers/facebook/actions/get-page-posts.action.ts +214 -225
- package/src/providers/facebook/actions/get-post-insights.action.ts +300 -316
- package/src/providers/facebook/actions/respond-to-comments.action.ts +319 -336
- package/src/providers/facebook/actions/schedule-post.action.ts +289 -292
- package/src/providers/facebook/actions/search-posts.action.ts +399 -413
- package/src/providers/facebook/facebook-base.action.ts +653 -670
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +184 -189
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +160 -161
- package/src/providers/hootsuite/actions/get-analytics.action.ts +249 -254
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +206 -207
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +206 -205
- package/src/providers/hootsuite/actions/search-posts.action.ts +351 -369
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +211 -209
- package/src/providers/hootsuite/hootsuite-base.action.ts +301 -307
- package/src/providers/instagram/actions/create-post.action.ts +276 -296
- package/src/providers/instagram/actions/create-story.action.ts +378 -394
- package/src/providers/instagram/actions/get-account-insights.action.ts +384 -420
- package/src/providers/instagram/actions/get-business-posts.action.ts +233 -242
- package/src/providers/instagram/actions/get-comments.action.ts +365 -377
- package/src/providers/instagram/actions/get-post-insights.action.ts +265 -273
- package/src/providers/instagram/actions/schedule-post.action.ts +233 -235
- package/src/providers/instagram/actions/search-posts.action.ts +512 -538
- package/src/providers/instagram/instagram-base.action.ts +368 -393
- package/src/providers/linkedin/actions/create-article.action.ts +275 -266
- package/src/providers/linkedin/actions/create-post.action.ts +179 -177
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +146 -147
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +138 -139
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +190 -189
- package/src/providers/linkedin/actions/schedule-post.action.ts +191 -189
- package/src/providers/linkedin/actions/search-posts.action.ts +275 -283
- package/src/providers/linkedin/linkedin-base.action.ts +407 -421
- package/src/providers/tiktok/tiktok-base.action.ts +305 -320
- package/src/providers/twitter/actions/create-thread.action.ts +203 -207
- package/src/providers/twitter/actions/create-tweet.action.ts +187 -188
- package/src/providers/twitter/actions/delete-tweet.action.ts +128 -129
- package/src/providers/twitter/actions/get-analytics.action.ts +402 -411
- package/src/providers/twitter/actions/get-mentions.action.ts +218 -219
- package/src/providers/twitter/actions/get-timeline.action.ts +232 -233
- package/src/providers/twitter/actions/schedule-tweet.action.ts +221 -222
- package/src/providers/twitter/actions/search-tweets.action.ts +540 -543
- package/src/providers/twitter/twitter-base.action.ts +541 -560
- package/src/providers/youtube/youtube-base.action.ts +320 -333
|
@@ -2,7 +2,7 @@ import { RegisterClass } from '@memberjunction/global';
|
|
|
2
2
|
import { FacebookBaseAction, FacebookAlbum } from '../facebook-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
4
|
import { MediaFile, SocialMediaErrorCode } from '../../../base/base-social.action';
|
|
5
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
5
|
+
import { LogStatus, LogError } from '@memberjunction/global';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import FormData from 'form-data';
|
|
8
8
|
import { BaseAction } from '@memberjunction/actions';
|
|
@@ -13,324 +13,308 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
13
13
|
*/
|
|
14
14
|
@RegisterClass(BaseAction, 'FacebookCreateAlbumAction')
|
|
15
15
|
export class FacebookCreateAlbumAction extends FacebookBaseAction {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
LogStatus(`Creating album "${albumName}" on Facebook page ${pageId}...`);
|
|
145
|
-
|
|
146
|
-
// Get page access token
|
|
147
|
-
const pageToken = await this.getPageAccessToken(pageId);
|
|
148
|
-
|
|
149
|
-
// Create the album
|
|
150
|
-
const albumData: any = {
|
|
151
|
-
name: albumName,
|
|
152
|
-
privacy: {
|
|
153
|
-
value: privacy
|
|
154
|
-
}
|
|
16
|
+
/**
|
|
17
|
+
* Get action description
|
|
18
|
+
*/
|
|
19
|
+
public get Description(): string {
|
|
20
|
+
return 'Creates a photo album on a Facebook page and optionally uploads photos to it';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Define the parameters for this action
|
|
25
|
+
*/
|
|
26
|
+
public get Params(): ActionParam[] {
|
|
27
|
+
return [
|
|
28
|
+
...this.commonSocialParams,
|
|
29
|
+
{
|
|
30
|
+
Name: 'PageID',
|
|
31
|
+
Type: 'Input',
|
|
32
|
+
Value: null,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
Name: 'AlbumName',
|
|
36
|
+
Type: 'Input',
|
|
37
|
+
Value: null,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
Name: 'Description',
|
|
41
|
+
Type: 'Input',
|
|
42
|
+
Value: null,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
Name: 'Location',
|
|
46
|
+
Type: 'Input',
|
|
47
|
+
Value: null,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
Name: 'Privacy',
|
|
51
|
+
Type: 'Input',
|
|
52
|
+
Value: 'EVERYONE',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
Name: 'Photos',
|
|
56
|
+
Type: 'Input',
|
|
57
|
+
Value: null,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
Name: 'PhotoCaptions',
|
|
61
|
+
Type: 'Input',
|
|
62
|
+
Value: null,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
Name: 'CoverPhotoIndex',
|
|
66
|
+
Type: 'Input',
|
|
67
|
+
Value: 0,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
Name: 'MakeAlbumPublic',
|
|
71
|
+
Type: 'Input',
|
|
72
|
+
Value: true,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Execute the action
|
|
79
|
+
*/
|
|
80
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
81
|
+
const { Params, ContextUser } = params;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
// Validate required parameters
|
|
85
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
86
|
+
const pageId = this.getParamValue(Params, 'PageID');
|
|
87
|
+
const albumName = this.getParamValue(Params, 'AlbumName');
|
|
88
|
+
|
|
89
|
+
if (!companyIntegrationId) {
|
|
90
|
+
return {
|
|
91
|
+
Success: false,
|
|
92
|
+
Message: 'CompanyIntegrationID is required',
|
|
93
|
+
ResultCode: 'INVALID_TOKEN',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!pageId) {
|
|
98
|
+
return {
|
|
99
|
+
Success: false,
|
|
100
|
+
Message: 'PageID is required',
|
|
101
|
+
ResultCode: 'MISSING_REQUIRED_PARAM',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!albumName) {
|
|
106
|
+
return {
|
|
107
|
+
Success: false,
|
|
108
|
+
Message: 'AlbumName is required',
|
|
109
|
+
ResultCode: 'MISSING_REQUIRED_PARAM',
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Initialize OAuth
|
|
114
|
+
if (!(await this.initializeOAuth(companyIntegrationId))) {
|
|
115
|
+
return {
|
|
116
|
+
Success: false,
|
|
117
|
+
Message: 'Failed to initialize Facebook OAuth connection',
|
|
118
|
+
ResultCode: 'INVALID_TOKEN',
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Get parameters
|
|
123
|
+
const description = this.getParamValue(Params, 'Description') as string;
|
|
124
|
+
const location = this.getParamValue(Params, 'Location') as string;
|
|
125
|
+
const privacy = this.getParamValue(Params, 'Privacy') as string;
|
|
126
|
+
const photos = this.getParamValue(Params, 'Photos') as MediaFile[];
|
|
127
|
+
const photoCaptions = this.getParamValue(Params, 'PhotoCaptions') as string[];
|
|
128
|
+
const coverPhotoIndex = (this.getParamValue(Params, 'CoverPhotoIndex') as number) || 0;
|
|
129
|
+
const makeAlbumPublic = this.getParamValue(Params, 'MakeAlbumPublic') !== false;
|
|
130
|
+
|
|
131
|
+
// Validate photos are images
|
|
132
|
+
if (photos && photos.length > 0) {
|
|
133
|
+
for (const photo of photos) {
|
|
134
|
+
if (!photo.mimeType.startsWith('image/')) {
|
|
135
|
+
return {
|
|
136
|
+
Success: false,
|
|
137
|
+
Message: `Only image files are allowed in albums. File ${photo.filename} is ${photo.mimeType}`,
|
|
138
|
+
ResultCode: 'INVALID_MEDIA',
|
|
155
139
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
LogStatus(`Creating album "${albumName}" on Facebook page ${pageId}...`);
|
|
145
|
+
|
|
146
|
+
// Get page access token
|
|
147
|
+
const pageToken = await this.getPageAccessToken(pageId);
|
|
148
|
+
|
|
149
|
+
// Create the album
|
|
150
|
+
const albumData: any = {
|
|
151
|
+
name: albumName,
|
|
152
|
+
privacy: {
|
|
153
|
+
value: privacy,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
if (description) {
|
|
158
|
+
albumData.message = description;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (location) {
|
|
162
|
+
albumData.location = location;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const albumResponse = await axios.post(`${this.apiBaseUrl}/${pageId}/albums`, albumData, {
|
|
166
|
+
params: {
|
|
167
|
+
access_token: pageToken,
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const albumId = albumResponse.data.id;
|
|
172
|
+
LogStatus(`Album created with ID: ${albumId}`);
|
|
173
|
+
|
|
174
|
+
// Upload photos if provided
|
|
175
|
+
const uploadedPhotos: any[] = [];
|
|
176
|
+
let coverPhotoId: string | null = null;
|
|
177
|
+
|
|
178
|
+
if (photos && photos.length > 0) {
|
|
179
|
+
LogStatus(`Uploading ${photos.length} photos to the album...`);
|
|
180
|
+
|
|
181
|
+
for (let i = 0; i < photos.length; i++) {
|
|
182
|
+
const photo = photos[i];
|
|
183
|
+
const caption = photoCaptions?.[i] || '';
|
|
184
|
+
|
|
185
|
+
try {
|
|
186
|
+
const photoId = await this.uploadPhotoToAlbum(
|
|
187
|
+
albumId,
|
|
188
|
+
photo,
|
|
189
|
+
caption,
|
|
190
|
+
pageToken,
|
|
191
|
+
!makeAlbumPublic // Keep unpublished if album is not public yet
|
|
173
192
|
);
|
|
174
193
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
let coverPhotoId: string | null = null;
|
|
181
|
-
|
|
182
|
-
if (photos && photos.length > 0) {
|
|
183
|
-
LogStatus(`Uploading ${photos.length} photos to the album...`);
|
|
184
|
-
|
|
185
|
-
for (let i = 0; i < photos.length; i++) {
|
|
186
|
-
const photo = photos[i];
|
|
187
|
-
const caption = photoCaptions?.[i] || '';
|
|
188
|
-
|
|
189
|
-
try {
|
|
190
|
-
const photoId = await this.uploadPhotoToAlbum(
|
|
191
|
-
albumId,
|
|
192
|
-
photo,
|
|
193
|
-
caption,
|
|
194
|
-
pageToken,
|
|
195
|
-
!makeAlbumPublic // Keep unpublished if album is not public yet
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
uploadedPhotos.push({
|
|
199
|
-
id: photoId,
|
|
200
|
-
filename: photo.filename,
|
|
201
|
-
caption
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
if (i === coverPhotoIndex) {
|
|
205
|
-
coverPhotoId = photoId;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
LogStatus(`Uploaded photo ${i + 1}/${photos.length}: ${photo.filename}`);
|
|
209
|
-
} catch (error) {
|
|
210
|
-
LogError(`Failed to upload photo ${photo.filename}: ${error}`);
|
|
211
|
-
// Continue with other photos
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
194
|
+
uploadedPhotos.push({
|
|
195
|
+
id: photoId,
|
|
196
|
+
filename: photo.filename,
|
|
197
|
+
caption,
|
|
198
|
+
});
|
|
215
199
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
try {
|
|
219
|
-
await this.setAlbumCoverPhoto(albumId, coverPhotoId, pageToken);
|
|
220
|
-
LogStatus(`Set cover photo for album`);
|
|
221
|
-
} catch (error) {
|
|
222
|
-
LogError(`Failed to set cover photo: ${error}`);
|
|
223
|
-
// Non-critical error, continue
|
|
224
|
-
}
|
|
200
|
+
if (i === coverPhotoIndex) {
|
|
201
|
+
coverPhotoId = photoId;
|
|
225
202
|
}
|
|
226
203
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
Message: `Album created successfully with ${uploadedPhotos.length} photos`,
|
|
235
|
-
ResultCode: 'SUCCESS',
|
|
236
|
-
Params
|
|
237
|
-
};
|
|
204
|
+
LogStatus(`Uploaded photo ${i + 1}/${photos.length}: ${photo.filename}`);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
LogError(`Failed to upload photo ${photo.filename}: ${error}`);
|
|
207
|
+
// Continue with other photos
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
238
211
|
|
|
212
|
+
// Set cover photo if specified and photos were uploaded
|
|
213
|
+
if (coverPhotoId) {
|
|
214
|
+
try {
|
|
215
|
+
await this.setAlbumCoverPhoto(albumId, coverPhotoId, pageToken);
|
|
216
|
+
LogStatus(`Set cover photo for album`);
|
|
239
217
|
} catch (error) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (this.isAuthError(error)) {
|
|
243
|
-
return this.handleOAuthError(error);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return {
|
|
247
|
-
Success: false,
|
|
248
|
-
Message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
249
|
-
ResultCode: 'ERROR'
|
|
250
|
-
};
|
|
218
|
+
LogError(`Failed to set cover photo: ${error}`);
|
|
219
|
+
// Non-critical error, continue
|
|
251
220
|
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Get the final album details
|
|
224
|
+
const album = await this.getAlbumDetails(albumId, pageToken);
|
|
225
|
+
|
|
226
|
+
LogStatus(`Album "${albumName}" created successfully with ${uploadedPhotos.length} photos`);
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
Success: true,
|
|
230
|
+
Message: `Album created successfully with ${uploadedPhotos.length} photos`,
|
|
231
|
+
ResultCode: 'SUCCESS',
|
|
232
|
+
Params,
|
|
233
|
+
};
|
|
234
|
+
} catch (error) {
|
|
235
|
+
LogError(`Failed to create Facebook album: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
236
|
+
|
|
237
|
+
if (this.isAuthError(error)) {
|
|
238
|
+
return this.handleOAuthError(error);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
Success: false,
|
|
243
|
+
Message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
244
|
+
ResultCode: 'ERROR',
|
|
245
|
+
};
|
|
252
246
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
formData.append('message', caption);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (unpublished) {
|
|
279
|
-
formData.append('published', 'false');
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const response = await axios.post(
|
|
283
|
-
`${this.apiBaseUrl}/${albumId}/photos`,
|
|
284
|
-
formData,
|
|
285
|
-
{
|
|
286
|
-
headers: formData.getHeaders(),
|
|
287
|
-
params: {
|
|
288
|
-
access_token: pageToken
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
return response.data.id;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Upload a photo to an album
|
|
251
|
+
*/
|
|
252
|
+
private async uploadPhotoToAlbum(
|
|
253
|
+
albumId: string,
|
|
254
|
+
photo: MediaFile,
|
|
255
|
+
caption: string,
|
|
256
|
+
pageToken: string,
|
|
257
|
+
unpublished: boolean = false
|
|
258
|
+
): Promise<string> {
|
|
259
|
+
const fileData = typeof photo.data === 'string' ? Buffer.from(photo.data, 'base64') : photo.data;
|
|
260
|
+
|
|
261
|
+
const formData = new FormData();
|
|
262
|
+
formData.append('source', fileData, {
|
|
263
|
+
filename: photo.filename,
|
|
264
|
+
contentType: photo.mimeType,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
if (caption) {
|
|
268
|
+
formData.append('message', caption);
|
|
294
269
|
}
|
|
295
270
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
*/
|
|
299
|
-
private async setAlbumCoverPhoto(albumId: string, photoId: string, pageToken: string): Promise<void> {
|
|
300
|
-
await axios.post(
|
|
301
|
-
`${this.apiBaseUrl}/${albumId}`,
|
|
302
|
-
{
|
|
303
|
-
cover_photo: photoId
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
params: {
|
|
307
|
-
access_token: pageToken
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
);
|
|
271
|
+
if (unpublished) {
|
|
272
|
+
formData.append('published', 'false');
|
|
311
273
|
}
|
|
312
274
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
275
|
+
const response = await axios.post(`${this.apiBaseUrl}/${albumId}/photos`, formData, {
|
|
276
|
+
headers: formData.getHeaders(),
|
|
277
|
+
params: {
|
|
278
|
+
access_token: pageToken,
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
return response.data.id;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Set the cover photo for an album
|
|
287
|
+
*/
|
|
288
|
+
private async setAlbumCoverPhoto(albumId: string, photoId: string, pageToken: string): Promise<void> {
|
|
289
|
+
await axios.post(
|
|
290
|
+
`${this.apiBaseUrl}/${albumId}`,
|
|
291
|
+
{
|
|
292
|
+
cover_photo: photoId,
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
params: {
|
|
296
|
+
access_token: pageToken,
|
|
297
|
+
},
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Get album details
|
|
304
|
+
*/
|
|
305
|
+
private async getAlbumDetails(albumId: string, pageToken: string): Promise<FacebookAlbum | null> {
|
|
306
|
+
try {
|
|
307
|
+
const response = await axios.get(`${this.apiBaseUrl}/${albumId}`, {
|
|
308
|
+
params: {
|
|
309
|
+
access_token: pageToken,
|
|
310
|
+
fields: 'id,name,description,link,cover_photo,count,created_time,photos.limit(1){id,images}',
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
return response.data;
|
|
315
|
+
} catch (error) {
|
|
316
|
+
LogError(`Failed to get album details: ${error}`);
|
|
317
|
+
return null;
|
|
333
318
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
319
|
+
}
|
|
320
|
+
}
|