Skip to content

Commit 98f6662

Browse files
committed
feat: linkedin fix
1 parent c8d93ae commit 98f6662

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

libraries/nestjs-libraries/src/integrations/social/linkedin.page.provider.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class LinkedinPageProvider
115115
headers: {
116116
Authorization: `Bearer ${accessToken}`,
117117
'X-Restli-Protocol-Version': '2.0.0',
118-
'LinkedIn-Version': '202402',
118+
'LinkedIn-Version': '202501',
119119
},
120120
}
121121
)
@@ -257,7 +257,7 @@ export class LinkedinPageProvider
257257

258258
const { elements }: { elements: Root[]; paging: any } = await (
259259
await this.fetch(
260-
`https://api.linkedin.com/rest/organizationPageStatistics?q=organization&organization=${encodeURIComponent(
260+
`https://api.linkedin.com/v2/organizationPageStatistics?q=organization&organization=${encodeURIComponent(
261261
`urn:li:organization:${id}`
262262
)}&timeIntervals=(timeRange:(start:${startDate},end:${endDate}),timeGranularityType:DAY)`,
263263
{
@@ -272,7 +272,7 @@ export class LinkedinPageProvider
272272

273273
const { elements: elements2 }: { elements: Root[]; paging: any } = await (
274274
await this.fetch(
275-
`https://api.linkedin.com/rest/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity=${encodeURIComponent(
275+
`https://api.linkedin.com/v2/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity=${encodeURIComponent(
276276
`urn:li:organization:${id}`
277277
)}&timeIntervals=(timeRange:(start:${startDate},end:${endDate}),timeGranularityType:DAY)`,
278278
{
@@ -287,7 +287,7 @@ export class LinkedinPageProvider
287287

288288
const { elements: elements3 }: { elements: Root[]; paging: any } = await (
289289
await this.fetch(
290-
`https://api.linkedin.com/rest/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=${encodeURIComponent(
290+
`https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=${encodeURIComponent(
291291
`urn:li:organization:${id}`
292292
)}&timeIntervals=(timeRange:(start:${startDate},end:${endDate}),timeGranularityType:DAY)`,
293293
{
@@ -404,7 +404,7 @@ export class LinkedinPageProvider
404404
headers: {
405405
'X-Restli-Protocol-Version': '2.0.0',
406406
'Content-Type': 'application/json',
407-
'LinkedIn-Version': '202402',
407+
'LinkedIn-Version': '202501',
408408
Authorization: `Bearer ${integration.token}`,
409409
},
410410
}
@@ -413,7 +413,7 @@ export class LinkedinPageProvider
413413

414414
if (totalLikes >= +fields.likesAmount) {
415415
await timer(2000);
416-
await this.fetch(`https://api.linkedin.com/rest/posts`, {
416+
await this.fetch(`https://api.linkedin.com/v2/posts`, {
417417
body: JSON.stringify({
418418
author: `urn:li:organization:${integration.internalId}`,
419419
commentary: '',
@@ -433,7 +433,7 @@ export class LinkedinPageProvider
433433
headers: {
434434
'X-Restli-Protocol-Version': '2.0.0',
435435
'Content-Type': 'application/json',
436-
'LinkedIn-Version': '202402',
436+
'LinkedIn-Version': '202501',
437437
Authorization: `Bearer ${integration.token}`,
438438
},
439439
});
@@ -482,7 +482,7 @@ export class LinkedinPageProvider
482482
headers: {
483483
'X-Restli-Protocol-Version': '2.0.0',
484484
'Content-Type': 'application/json',
485-
'LinkedIn-Version': '202402',
485+
'LinkedIn-Version': '202501',
486486
Authorization: `Bearer ${integration.token}`,
487487
},
488488
}

libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
171171

172172
const { elements } = await (
173173
await this.fetch(
174-
`https://api.linkedin.com/rest/organizations?q=vanityName&vanityName=${getCompanyVanity[1]}`,
174+
`https://api.linkedin.com/v2/organizations?q=vanityName&vanityName=${getCompanyVanity[1]}`,
175175
{
176176
method: 'GET',
177177
headers: {
178178
'Content-Type': 'application/json',
179179
'X-Restli-Protocol-Version': '2.0.0',
180-
'LinkedIn-Version': '202402',
180+
'LinkedIn-Version': '202501',
181181
Authorization: `Bearer ${token}`,
182182
},
183183
}
@@ -203,15 +203,15 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
203203
value: { uploadUrl, image, video, uploadInstructions, ...all },
204204
} = await (
205205
await this.fetch(
206-
`https://api.linkedin.com/rest/${
206+
`https://api.linkedin.com/v2/${
207207
fileName.indexOf('mp4') > -1 ? 'videos' : 'images'
208208
}?action=initializeUpload`,
209209
{
210210
method: 'POST',
211211
headers: {
212212
'Content-Type': 'application/json',
213213
'X-Restli-Protocol-Version': '2.0.0',
214-
'LinkedIn-Version': '202402',
214+
'LinkedIn-Version': '202501',
215215
Authorization: `Bearer ${accessToken}`,
216216
},
217217
body: JSON.stringify({
@@ -242,7 +242,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
242242
method: 'PUT',
243243
headers: {
244244
'X-Restli-Protocol-Version': '2.0.0',
245-
'LinkedIn-Version': '202402',
245+
'LinkedIn-Version': '202501',
246246
Authorization: `Bearer ${accessToken}`,
247247
...(fileName.indexOf('mp4') > -1
248248
? { 'Content-Type': 'application/octet-stream' }
@@ -256,7 +256,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
256256

257257
if (fileName.indexOf('mp4') > -1) {
258258
const a = await this.fetch(
259-
'https://api.linkedin.com/rest/videos?action=finalizeUpload',
259+
'https://api.linkedin.com/v2/videos?action=finalizeUpload',
260260
{
261261
method: 'POST',
262262
body: JSON.stringify({
@@ -268,7 +268,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
268268
}),
269269
headers: {
270270
'X-Restli-Protocol-Version': '2.0.0',
271-
'LinkedIn-Version': '202402',
271+
'LinkedIn-Version': '202501',
272272
'Content-Type': 'application/json',
273273
Authorization: `Bearer ${accessToken}`,
274274
},
@@ -472,7 +472,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
472472
isPersonal = true
473473
) {
474474
try {
475-
await this.fetch(`https://api.linkedin.com/rest/posts`, {
475+
await this.fetch(`https://api.linkedin.com/v2/posts`, {
476476
body: JSON.stringify({
477477
author:
478478
(isPersonal ? 'urn:li:person:' : `urn:li:organization:`) +
@@ -494,7 +494,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
494494
headers: {
495495
'X-Restli-Protocol-Version': '2.0.0',
496496
'Content-Type': 'application/json',
497-
'LinkedIn-Version': '202402',
497+
'LinkedIn-Version': '202501',
498498
Authorization: `Bearer ${integration.token}`,
499499
},
500500
});

0 commit comments

Comments
 (0)