@memberjunction/actions-bizapps-social 2.112.0 → 2.113.1
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 +13 -0
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +24 -18
- 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 +34 -35
- 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 +36 -34
- 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 +27 -25
- 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 +23 -19
- 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 +32 -28
- 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 +44 -42
- 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 +39 -37
- 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 +59 -44
- 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 +31 -33
- 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 +32 -28
- 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 +26 -24
- 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 +34 -32
- 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 +52 -43
- 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 +28 -30
- 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 +20 -18
- 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 +26 -27
- 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 +59 -38
- 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 +25 -23
- 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 +60 -56
- 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 +27 -25
- 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 +45 -55
- 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 +29 -31
- 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 +23 -25
- 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 +30 -32
- 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 +30 -28
- 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 +38 -33
- 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 +26 -25
- 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 +29 -25
- 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 +47 -40
- 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 +31 -30
- 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 +58 -56
- 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 +68 -58
- 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 +25 -22
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +6 -5
- package/src/base/base-social.action.ts +224 -217
- package/src/providers/buffer/buffer-base.action.ts +441 -435
- package/src/providers/facebook/actions/boost-post.action.ts +386 -350
- package/src/providers/facebook/actions/create-album.action.ts +307 -291
- package/src/providers/facebook/actions/create-post.action.ts +227 -224
- package/src/providers/facebook/actions/get-page-insights.action.ts +403 -383
- package/src/providers/facebook/actions/get-page-posts.action.ts +225 -214
- package/src/providers/facebook/actions/get-post-insights.action.ts +316 -300
- package/src/providers/facebook/actions/respond-to-comments.action.ts +336 -319
- package/src/providers/facebook/actions/schedule-post.action.ts +292 -289
- package/src/providers/facebook/actions/search-posts.action.ts +413 -399
- package/src/providers/facebook/facebook-base.action.ts +670 -653
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +189 -184
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +161 -160
- package/src/providers/hootsuite/actions/get-analytics.action.ts +254 -249
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +207 -206
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +205 -206
- package/src/providers/hootsuite/actions/search-posts.action.ts +369 -351
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +209 -211
- package/src/providers/hootsuite/hootsuite-base.action.ts +307 -301
- package/src/providers/instagram/actions/create-post.action.ts +296 -276
- package/src/providers/instagram/actions/create-story.action.ts +394 -378
- package/src/providers/instagram/actions/get-account-insights.action.ts +420 -384
- package/src/providers/instagram/actions/get-business-posts.action.ts +242 -233
- package/src/providers/instagram/actions/get-comments.action.ts +377 -365
- package/src/providers/instagram/actions/get-post-insights.action.ts +273 -265
- package/src/providers/instagram/actions/schedule-post.action.ts +235 -233
- package/src/providers/instagram/actions/search-posts.action.ts +538 -512
- package/src/providers/instagram/instagram-base.action.ts +393 -368
- package/src/providers/linkedin/actions/create-article.action.ts +266 -275
- package/src/providers/linkedin/actions/create-post.action.ts +177 -179
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +147 -146
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +139 -138
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +189 -190
- package/src/providers/linkedin/actions/schedule-post.action.ts +189 -191
- package/src/providers/linkedin/actions/search-posts.action.ts +283 -275
- package/src/providers/linkedin/linkedin-base.action.ts +421 -407
- package/src/providers/tiktok/tiktok-base.action.ts +320 -305
- package/src/providers/twitter/actions/create-thread.action.ts +207 -203
- package/src/providers/twitter/actions/create-tweet.action.ts +188 -187
- package/src/providers/twitter/actions/delete-tweet.action.ts +129 -128
- package/src/providers/twitter/actions/get-analytics.action.ts +411 -402
- package/src/providers/twitter/actions/get-mentions.action.ts +219 -218
- package/src/providers/twitter/actions/get-timeline.action.ts +233 -232
- package/src/providers/twitter/actions/schedule-tweet.action.ts +222 -221
- package/src/providers/twitter/actions/search-tweets.action.ts +543 -540
- package/src/providers/twitter/twitter-base.action.ts +560 -541
- package/src/providers/youtube/youtube-base.action.ts +333 -320
|
@@ -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/core';
|
|
5
5
|
import { SocialPost } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,155 +10,156 @@ 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
|
-
|
|
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.');
|
|
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
|
+
};
|
|
39
93
|
}
|
|
40
|
-
|
|
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);
|
|
94
|
+
}
|
|
54
95
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Get analytics for a specific post
|
|
98
|
+
*/
|
|
99
|
+
private async getPostAnalytics(shareId: string, organizationUrn: string): Promise<any> {
|
|
100
|
+
try {
|
|
101
|
+
const response = await this.axiosInstance.get('/organizationalEntityShareStatistics', {
|
|
102
|
+
params: {
|
|
103
|
+
q: 'organizationalEntity',
|
|
104
|
+
organizationalEntity: organizationUrn,
|
|
105
|
+
shares: `List(${shareId})`
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (response.data.elements && response.data.elements.length > 0) {
|
|
110
|
+
return response.data.elements[0];
|
|
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;
|
|
63
117
|
}
|
|
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
|
-
} 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
|
-
};
|
|
92
118
|
}
|
|
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
|
-
});
|
|
107
119
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Define the parameters this action expects
|
|
122
|
+
*/
|
|
123
|
+
public get Params(): ActionParam[] {
|
|
124
|
+
return [
|
|
125
|
+
...this.commonSocialParams,
|
|
126
|
+
{
|
|
127
|
+
Name: 'OrganizationID',
|
|
128
|
+
Type: 'Input',
|
|
129
|
+
Value: null
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
Name: 'Count',
|
|
133
|
+
Type: 'Input',
|
|
134
|
+
Value: 50
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
Name: 'StartIndex',
|
|
138
|
+
Type: 'Input',
|
|
139
|
+
Value: 0
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
Name: 'IncludeAnalytics',
|
|
143
|
+
Type: 'Input',
|
|
144
|
+
Value: false
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
Name: 'Posts',
|
|
148
|
+
Type: 'Output',
|
|
149
|
+
Value: null
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
Name: 'TotalCount',
|
|
153
|
+
Type: 'Output',
|
|
154
|
+
Value: null
|
|
155
|
+
}
|
|
156
|
+
];
|
|
116
157
|
}
|
|
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
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
159
|
+
/**
|
|
160
|
+
* Get action description
|
|
161
|
+
*/
|
|
162
|
+
public get Description(): string {
|
|
163
|
+
return 'Retrieves posts from a LinkedIn organization page with optional analytics data';
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -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/core';
|
|
5
5
|
import { SocialPost } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,149 +10,150 @@ 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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
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;
|
|
30
|
-
|
|
31
|
-
// Get current user URN
|
|
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);
|
|
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;
|
|
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');
|
|
50
24
|
}
|
|
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
25
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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;
|
|
30
|
+
|
|
31
|
+
// Get current user URN
|
|
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
|
+
}
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
|
|
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
|
+
}
|
|
83
85
|
}
|
|
84
|
-
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Get analytics for a personal post
|
|
89
|
+
* Note: LinkedIn provides limited analytics for personal posts
|
|
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
|
+
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
return null;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
LogError(`Failed to get personal post analytics: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
115
117
|
}
|
|
116
|
-
}
|
|
117
118
|
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Define the parameters this action expects
|
|
121
|
+
*/
|
|
122
|
+
public get Params(): ActionParam[] {
|
|
123
|
+
return [
|
|
124
|
+
...this.commonSocialParams,
|
|
125
|
+
{
|
|
126
|
+
Name: 'Count',
|
|
127
|
+
Type: 'Input',
|
|
128
|
+
Value: 50
|
|
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
|
|
149
|
+
}
|
|
150
|
+
];
|
|
151
|
+
}
|
|
151
152
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
153
|
+
/**
|
|
154
|
+
* Get action description
|
|
155
|
+
*/
|
|
156
|
+
public get Description(): string {
|
|
157
|
+
return 'Retrieves posts from the authenticated user\'s LinkedIn personal profile with limited analytics data';
|
|
158
|
+
}
|
|
159
|
+
}
|