@memberjunction/actions-bizapps-social 2.111.0 → 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { LinkedInBaseAction } from '../linkedin-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
4
|
+
import { LogStatus, LogError } from '@memberjunction/global';
|
|
5
5
|
import { SocialPost } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,156 +10,155 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
10
10
|
*/
|
|
11
11
|
@RegisterClass(BaseAction, 'LinkedInGetOrganizationPostsAction')
|
|
12
12
|
export class LinkedInGetOrganizationPostsAction extends LinkedInBaseAction {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
organizationUrn = orgs[0].urn;
|
|
41
|
-
LogStatus(`Using organization: ${orgs[0].name}`);
|
|
42
|
-
} else {
|
|
43
|
-
organizationUrn = `urn:li:organization:${organizationId}`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Get posts
|
|
47
|
-
LogStatus(`Fetching posts for organization...`);
|
|
48
|
-
const shares = await this.getShares(organizationUrn, count, startIndex);
|
|
49
|
-
|
|
50
|
-
// Convert to common format
|
|
51
|
-
const posts: SocialPost[] = [];
|
|
52
|
-
for (const share of shares) {
|
|
53
|
-
const post = this.normalizePost(share);
|
|
54
|
-
|
|
55
|
-
// Optionally fetch analytics
|
|
56
|
-
if (includeAnalytics) {
|
|
57
|
-
try {
|
|
58
|
-
const analytics = await this.getPostAnalytics(share.id, organizationUrn);
|
|
59
|
-
post.analytics = this.normalizeAnalytics(analytics);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
LogError(`Failed to get analytics for post ${share.id}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
posts.push(post);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
LogStatus(`Retrieved ${posts.length} posts`);
|
|
69
|
-
|
|
70
|
-
// Update output parameters
|
|
71
|
-
const outputParams = [...Params];
|
|
72
|
-
const postsParam = outputParams.find(p => p.Name === 'Posts');
|
|
73
|
-
if (postsParam) postsParam.Value = posts;
|
|
74
|
-
const totalCountParam = outputParams.find(p => p.Name === 'TotalCount');
|
|
75
|
-
if (totalCountParam) totalCountParam.Value = posts.length;
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
Success: true,
|
|
79
|
-
ResultCode: 'SUCCESS',
|
|
80
|
-
Message: `Successfully retrieved ${posts.length} organization posts`,
|
|
81
|
-
Params: outputParams
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
} catch (error) {
|
|
85
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
Success: false,
|
|
89
|
-
ResultCode: 'ERROR',
|
|
90
|
-
Message: `Failed to get organization posts: ${errorMessage}`,
|
|
91
|
-
Params
|
|
92
|
-
};
|
|
13
|
+
/**
|
|
14
|
+
* Get posts from a LinkedIn organization page
|
|
15
|
+
*/
|
|
16
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
17
|
+
const { Params, ContextUser } = params;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Initialize OAuth
|
|
21
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
22
|
+
if (!(await this.initializeOAuth(companyIntegrationId))) {
|
|
23
|
+
throw new Error('Failed to initialize OAuth connection');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Extract parameters
|
|
27
|
+
const organizationId = this.getParamValue(Params, 'OrganizationID');
|
|
28
|
+
const count = this.getParamValue(Params, 'Count') || 50;
|
|
29
|
+
const startIndex = this.getParamValue(Params, 'StartIndex') || 0;
|
|
30
|
+
const includeAnalytics = this.getParamValue(Params, 'IncludeAnalytics') === true;
|
|
31
|
+
|
|
32
|
+
// Determine organization URN
|
|
33
|
+
let organizationUrn: string;
|
|
34
|
+
if (!organizationId) {
|
|
35
|
+
// Get first admin organization if not specified
|
|
36
|
+
const orgs = await this.getAdminOrganizations();
|
|
37
|
+
if (orgs.length === 0) {
|
|
38
|
+
throw new Error('No organizations found. Please specify OrganizationID.');
|
|
93
39
|
}
|
|
94
|
-
|
|
40
|
+
organizationUrn = orgs[0].urn;
|
|
41
|
+
LogStatus(`Using organization: ${orgs[0].name}`);
|
|
42
|
+
} else {
|
|
43
|
+
organizationUrn = `urn:li:organization:${organizationId}`;
|
|
44
|
+
}
|
|
95
45
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return null;
|
|
114
|
-
} catch (error) {
|
|
115
|
-
LogError(`Failed to get post analytics: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
116
|
-
return null;
|
|
46
|
+
// Get posts
|
|
47
|
+
LogStatus(`Fetching posts for organization...`);
|
|
48
|
+
const shares = await this.getShares(organizationUrn, count, startIndex);
|
|
49
|
+
|
|
50
|
+
// Convert to common format
|
|
51
|
+
const posts: SocialPost[] = [];
|
|
52
|
+
for (const share of shares) {
|
|
53
|
+
const post = this.normalizePost(share);
|
|
54
|
+
|
|
55
|
+
// Optionally fetch analytics
|
|
56
|
+
if (includeAnalytics) {
|
|
57
|
+
try {
|
|
58
|
+
const analytics = await this.getPostAnalytics(share.id, organizationUrn);
|
|
59
|
+
post.analytics = this.normalizeAnalytics(analytics);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
LogError(`Failed to get analytics for post ${share.id}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
62
|
+
}
|
|
117
63
|
}
|
|
118
|
-
}
|
|
119
64
|
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Name: 'Posts',
|
|
148
|
-
Type: 'Output',
|
|
149
|
-
Value: null
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
Name: 'TotalCount',
|
|
153
|
-
Type: 'Output',
|
|
154
|
-
Value: null
|
|
155
|
-
}
|
|
156
|
-
];
|
|
65
|
+
posts.push(post);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
LogStatus(`Retrieved ${posts.length} posts`);
|
|
69
|
+
|
|
70
|
+
// Update output parameters
|
|
71
|
+
const outputParams = [...Params];
|
|
72
|
+
const postsParam = outputParams.find((p) => p.Name === 'Posts');
|
|
73
|
+
if (postsParam) postsParam.Value = posts;
|
|
74
|
+
const totalCountParam = outputParams.find((p) => p.Name === 'TotalCount');
|
|
75
|
+
if (totalCountParam) totalCountParam.Value = posts.length;
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
Success: true,
|
|
79
|
+
ResultCode: 'SUCCESS',
|
|
80
|
+
Message: `Successfully retrieved ${posts.length} organization posts`,
|
|
81
|
+
Params: outputParams,
|
|
82
|
+
};
|
|
83
|
+
} catch (error) {
|
|
84
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
Success: false,
|
|
88
|
+
ResultCode: 'ERROR',
|
|
89
|
+
Message: `Failed to get organization posts: ${errorMessage}`,
|
|
90
|
+
Params,
|
|
91
|
+
};
|
|
157
92
|
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get analytics for a specific post
|
|
97
|
+
*/
|
|
98
|
+
private async getPostAnalytics(shareId: string, organizationUrn: string): Promise<any> {
|
|
99
|
+
try {
|
|
100
|
+
const response = await this.axiosInstance.get('/organizationalEntityShareStatistics', {
|
|
101
|
+
params: {
|
|
102
|
+
q: 'organizationalEntity',
|
|
103
|
+
organizationalEntity: organizationUrn,
|
|
104
|
+
shares: `List(${shareId})`,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
158
107
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
108
|
+
if (response.data.elements && response.data.elements.length > 0) {
|
|
109
|
+
return response.data.elements[0];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return null;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
LogError(`Failed to get post analytics: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
115
|
+
return null;
|
|
164
116
|
}
|
|
165
|
-
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Define the parameters this action expects
|
|
121
|
+
*/
|
|
122
|
+
public get Params(): ActionParam[] {
|
|
123
|
+
return [
|
|
124
|
+
...this.commonSocialParams,
|
|
125
|
+
{
|
|
126
|
+
Name: 'OrganizationID',
|
|
127
|
+
Type: 'Input',
|
|
128
|
+
Value: null,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
Name: 'Count',
|
|
132
|
+
Type: 'Input',
|
|
133
|
+
Value: 50,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
Name: 'StartIndex',
|
|
137
|
+
Type: 'Input',
|
|
138
|
+
Value: 0,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
Name: 'IncludeAnalytics',
|
|
142
|
+
Type: 'Input',
|
|
143
|
+
Value: false,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
Name: 'Posts',
|
|
147
|
+
Type: 'Output',
|
|
148
|
+
Value: null,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
Name: 'TotalCount',
|
|
152
|
+
Type: 'Output',
|
|
153
|
+
Value: null,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get action description
|
|
160
|
+
*/
|
|
161
|
+
public get Description(): string {
|
|
162
|
+
return 'Retrieves posts from a LinkedIn organization page with optional analytics data';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { LinkedInBaseAction } from '../linkedin-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
4
|
+
import { LogStatus, LogError } from '@memberjunction/global';
|
|
5
5
|
import { SocialPost } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,150 +10,149 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
10
10
|
*/
|
|
11
11
|
@RegisterClass(BaseAction, 'LinkedInGetPersonalPostsAction')
|
|
12
12
|
export class LinkedInGetPersonalPostsAction extends LinkedInBaseAction {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
// Initialize OAuth
|
|
21
|
-
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
22
|
-
if (!await this.initializeOAuth(companyIntegrationId)) {
|
|
23
|
-
throw new Error('Failed to initialize OAuth connection');
|
|
24
|
-
}
|
|
13
|
+
/**
|
|
14
|
+
* Get posts from the authenticated user's LinkedIn profile
|
|
15
|
+
*/
|
|
16
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
17
|
+
const { Params, ContextUser } = params;
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const userUrn = await this.getCurrentUserUrn();
|
|
33
|
-
LogStatus(`Fetching posts for user: ${userUrn}`);
|
|
34
|
-
|
|
35
|
-
// Get posts
|
|
36
|
-
const shares = await this.getShares(userUrn, count, startIndex);
|
|
37
|
-
|
|
38
|
-
// Convert to common format
|
|
39
|
-
const posts: SocialPost[] = [];
|
|
40
|
-
for (const share of shares) {
|
|
41
|
-
const post = this.normalizePost(share);
|
|
42
|
-
|
|
43
|
-
// Personal posts have limited analytics access
|
|
44
|
-
if (includeAnalytics) {
|
|
45
|
-
try {
|
|
46
|
-
// Note: Personal share analytics are limited compared to organization analytics
|
|
47
|
-
const analytics = await this.getPersonalPostAnalytics(share.id);
|
|
48
|
-
if (analytics) {
|
|
49
|
-
post.analytics = this.normalizeAnalytics(analytics);
|
|
50
|
-
}
|
|
51
|
-
} catch (error) {
|
|
52
|
-
LogError(`Failed to get analytics for post ${share.id}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
posts.push(post);
|
|
57
|
-
}
|
|
19
|
+
try {
|
|
20
|
+
// Initialize OAuth
|
|
21
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
22
|
+
if (!(await this.initializeOAuth(companyIntegrationId))) {
|
|
23
|
+
throw new Error('Failed to initialize OAuth connection');
|
|
24
|
+
}
|
|
58
25
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const postsParam = outputParams.find(p => p.Name === 'Posts');
|
|
64
|
-
if (postsParam) postsParam.Value = posts;
|
|
65
|
-
const totalCountParam = outputParams.find(p => p.Name === 'TotalCount');
|
|
66
|
-
if (totalCountParam) totalCountParam.Value = posts.length;
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
Success: true,
|
|
70
|
-
ResultCode: 'SUCCESS',
|
|
71
|
-
Message: `Successfully retrieved ${posts.length} personal posts`,
|
|
72
|
-
Params: outputParams
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
} catch (error) {
|
|
76
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
Success: false,
|
|
80
|
-
ResultCode: 'ERROR',
|
|
81
|
-
Message: `Failed to get personal posts: ${errorMessage}`,
|
|
82
|
-
Params
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
26
|
+
// Extract parameters
|
|
27
|
+
const count = this.getParamValue(Params, 'Count') || 50;
|
|
28
|
+
const startIndex = this.getParamValue(Params, 'StartIndex') || 0;
|
|
29
|
+
const includeAnalytics = this.getParamValue(Params, 'IncludeAnalytics') === true;
|
|
86
30
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*/
|
|
91
|
-
private async getPersonalPostAnalytics(shareId: string): Promise<any> {
|
|
92
|
-
try {
|
|
93
|
-
// LinkedIn v2 API has limited personal analytics
|
|
94
|
-
// We can get basic engagement data from the share itself
|
|
95
|
-
const response = await this.axiosInstance.get(`/ugcPosts/${shareId}`);
|
|
96
|
-
|
|
97
|
-
if (response.data) {
|
|
98
|
-
// Extract available metrics from the post data
|
|
99
|
-
return {
|
|
100
|
-
totalShareStatistics: {
|
|
101
|
-
impressionCount: 0, // Not available for personal posts
|
|
102
|
-
clickCount: 0, // Not available for personal posts
|
|
103
|
-
engagement: 0, // Not available for personal posts
|
|
104
|
-
likeCount: response.data.likesSummary?.totalLikes || 0,
|
|
105
|
-
commentCount: response.data.commentsSummary?.totalComments || 0,
|
|
106
|
-
shareCount: 0, // Not available in this endpoint
|
|
107
|
-
uniqueImpressionsCount: 0 // Not available for personal posts
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
31
|
+
// Get current user URN
|
|
32
|
+
const userUrn = await this.getCurrentUserUrn();
|
|
33
|
+
LogStatus(`Fetching posts for user: ${userUrn}`);
|
|
111
34
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
LogError(`Failed to get personal post analytics: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
35
|
+
// Get posts
|
|
36
|
+
const shares = await this.getShares(userUrn, count, startIndex);
|
|
118
37
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Name: 'StartIndex',
|
|
132
|
-
Type: 'Input',
|
|
133
|
-
Value: 0
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
Name: 'IncludeAnalytics',
|
|
137
|
-
Type: 'Input',
|
|
138
|
-
Value: false
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
Name: 'Posts',
|
|
142
|
-
Type: 'Output',
|
|
143
|
-
Value: null
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
Name: 'TotalCount',
|
|
147
|
-
Type: 'Output',
|
|
148
|
-
Value: null
|
|
38
|
+
// Convert to common format
|
|
39
|
+
const posts: SocialPost[] = [];
|
|
40
|
+
for (const share of shares) {
|
|
41
|
+
const post = this.normalizePost(share);
|
|
42
|
+
|
|
43
|
+
// Personal posts have limited analytics access
|
|
44
|
+
if (includeAnalytics) {
|
|
45
|
+
try {
|
|
46
|
+
// Note: Personal share analytics are limited compared to organization analytics
|
|
47
|
+
const analytics = await this.getPersonalPostAnalytics(share.id);
|
|
48
|
+
if (analytics) {
|
|
49
|
+
post.analytics = this.normalizeAnalytics(analytics);
|
|
149
50
|
}
|
|
150
|
-
|
|
51
|
+
} catch (error) {
|
|
52
|
+
LogError(`Failed to get analytics for post ${share.id}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
posts.push(post);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
LogStatus(`Retrieved ${posts.length} personal posts`);
|
|
60
|
+
|
|
61
|
+
// Update output parameters
|
|
62
|
+
const outputParams = [...Params];
|
|
63
|
+
const postsParam = outputParams.find((p) => p.Name === 'Posts');
|
|
64
|
+
if (postsParam) postsParam.Value = posts;
|
|
65
|
+
const totalCountParam = outputParams.find((p) => p.Name === 'TotalCount');
|
|
66
|
+
if (totalCountParam) totalCountParam.Value = posts.length;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
Success: true,
|
|
70
|
+
ResultCode: 'SUCCESS',
|
|
71
|
+
Message: `Successfully retrieved ${posts.length} personal posts`,
|
|
72
|
+
Params: outputParams,
|
|
73
|
+
};
|
|
74
|
+
} catch (error) {
|
|
75
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
Success: false,
|
|
79
|
+
ResultCode: 'ERROR',
|
|
80
|
+
Message: `Failed to get personal posts: ${errorMessage}`,
|
|
81
|
+
Params,
|
|
82
|
+
};
|
|
151
83
|
}
|
|
84
|
+
}
|
|
152
85
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Get analytics for a personal post
|
|
88
|
+
* Note: LinkedIn provides limited analytics for personal posts
|
|
89
|
+
*/
|
|
90
|
+
private async getPersonalPostAnalytics(shareId: string): Promise<any> {
|
|
91
|
+
try {
|
|
92
|
+
// LinkedIn v2 API has limited personal analytics
|
|
93
|
+
// We can get basic engagement data from the share itself
|
|
94
|
+
const response = await this.axiosInstance.get(`/ugcPosts/${shareId}`);
|
|
95
|
+
|
|
96
|
+
if (response.data) {
|
|
97
|
+
// Extract available metrics from the post data
|
|
98
|
+
return {
|
|
99
|
+
totalShareStatistics: {
|
|
100
|
+
impressionCount: 0, // Not available for personal posts
|
|
101
|
+
clickCount: 0, // Not available for personal posts
|
|
102
|
+
engagement: 0, // Not available for personal posts
|
|
103
|
+
likeCount: response.data.likesSummary?.totalLikes || 0,
|
|
104
|
+
commentCount: response.data.commentsSummary?.totalComments || 0,
|
|
105
|
+
shareCount: 0, // Not available in this endpoint
|
|
106
|
+
uniqueImpressionsCount: 0, // Not available for personal posts
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return null;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
LogError(`Failed to get personal post analytics: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
114
|
+
return null;
|
|
158
115
|
}
|
|
159
|
-
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Define the parameters this action expects
|
|
120
|
+
*/
|
|
121
|
+
public get Params(): ActionParam[] {
|
|
122
|
+
return [
|
|
123
|
+
...this.commonSocialParams,
|
|
124
|
+
{
|
|
125
|
+
Name: 'Count',
|
|
126
|
+
Type: 'Input',
|
|
127
|
+
Value: 50,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
Name: 'StartIndex',
|
|
131
|
+
Type: 'Input',
|
|
132
|
+
Value: 0,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
Name: 'IncludeAnalytics',
|
|
136
|
+
Type: 'Input',
|
|
137
|
+
Value: false,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
Name: 'Posts',
|
|
141
|
+
Type: 'Output',
|
|
142
|
+
Value: null,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
Name: 'TotalCount',
|
|
146
|
+
Type: 'Output',
|
|
147
|
+
Value: null,
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Get action description
|
|
154
|
+
*/
|
|
155
|
+
public get Description(): string {
|
|
156
|
+
return "Retrieves posts from the authenticated user's LinkedIn personal profile with limited analytics data";
|
|
157
|
+
}
|
|
158
|
+
}
|