2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2023-02-27 19:39:43 -08:00
|
|
|
IDataObject,
|
2023-03-06 08:33:32 -08:00
|
|
|
IExecuteFunctions,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
ILoadOptionsFunctions,
|
2020-10-01 05:01:39 -07:00
|
|
|
INodeExecutionData,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
INodePropertyOptions,
|
2020-10-01 05:01:39 -07:00
|
|
|
INodeType,
|
|
|
|
INodeTypeDescription,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
import { linkedInApiRequest } from './GenericFunctions';
|
2022-08-17 08:50:24 -07:00
|
|
|
import { postFields, postOperations } from './PostDescription';
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
|
|
|
export class LinkedIn implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'LinkedIn',
|
|
|
|
name: 'linkedIn',
|
2022-06-23 14:15:29 -07:00
|
|
|
icon: 'file:linkedin.svg',
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
group: ['input'],
|
|
|
|
version: 1,
|
2022-06-23 14:15:29 -07:00
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
2021-07-03 05:40:16 -07:00
|
|
|
description: 'Consume LinkedIn API',
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
defaults: {
|
|
|
|
name: 'LinkedIn',
|
|
|
|
},
|
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'linkedInOAuth2Api',
|
|
|
|
required: true,
|
2024-01-24 01:28:42 -08:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
authentication: ['standard'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'linkedInCommunityManagementOAuth2Api',
|
|
|
|
required: true,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
authentication: ['communityManagement'],
|
|
|
|
},
|
|
|
|
},
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
properties: [
|
2024-01-24 01:28:42 -08:00
|
|
|
{
|
|
|
|
displayName: 'Authentication',
|
|
|
|
name: 'authentication',
|
|
|
|
type: 'options',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Standard',
|
|
|
|
value: 'standard',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Community Management',
|
|
|
|
value: 'communityManagement',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'standard',
|
|
|
|
},
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
noDataExpression: true,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Post',
|
|
|
|
value: 'post',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'post',
|
|
|
|
},
|
|
|
|
//POST
|
|
|
|
...postOperations,
|
|
|
|
...postFields,
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
methods = {
|
|
|
|
loadOptions: {
|
|
|
|
// Get Person URN which has to be used with other LinkedIn API Requests
|
|
|
|
// https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin
|
|
|
|
async getPersonUrn(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
2024-01-24 01:28:42 -08:00
|
|
|
const authentication = this.getNodeParameter('authentication', 0);
|
2024-07-02 08:45:30 -07:00
|
|
|
let endpoint = '/v2/me';
|
2024-01-24 01:28:42 -08:00
|
|
|
if (authentication === 'standard') {
|
|
|
|
const { legacy } = await this.getCredentials('linkedInOAuth2Api');
|
|
|
|
if (!legacy) {
|
|
|
|
endpoint = '/v2/userinfo';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const person = await linkedInApiRequest.call(this, 'GET', endpoint, {});
|
|
|
|
const firstName = person.localizedFirstName ?? person.given_name;
|
|
|
|
const lastName = person.localizedLastName ?? person.family_name;
|
|
|
|
const name = `${firstName} ${lastName}`;
|
|
|
|
const returnData: INodePropertyOptions[] = [
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
value: person.id ?? person.sub,
|
|
|
|
},
|
|
|
|
];
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
return returnData;
|
|
|
|
},
|
2020-10-22 06:46:03 -07:00
|
|
|
},
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
const items = this.getInputData();
|
2023-01-31 11:39:20 -08:00
|
|
|
const returnData: INodeExecutionData[] = [];
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
let responseData;
|
2022-12-02 03:53:59 -08:00
|
|
|
const resource = this.getNodeParameter('resource', 0);
|
|
|
|
const operation = this.getNodeParameter('operation', 0);
|
2022-06-23 14:15:29 -07:00
|
|
|
|
2022-12-02 06:25:21 -08:00
|
|
|
let body: any = {};
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
2021-07-19 23:58:54 -07:00
|
|
|
try {
|
|
|
|
if (resource === 'post') {
|
|
|
|
if (operation === 'create') {
|
|
|
|
const text = this.getNodeParameter('text', i) as string;
|
|
|
|
const shareMediaCategory = this.getNodeParameter('shareMediaCategory', i) as string;
|
|
|
|
const postAs = this.getNodeParameter('postAs', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
let authorUrn = '';
|
|
|
|
let visibility = 'PUBLIC';
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (postAs === 'person') {
|
|
|
|
const personUrn = this.getNodeParameter('person', i) as string;
|
|
|
|
// Only if posting as a person can user decide if post visible by public or connections
|
2022-08-17 08:50:24 -07:00
|
|
|
visibility = (additionalFields.visibility as string) || 'PUBLIC';
|
2021-07-19 23:58:54 -07:00
|
|
|
authorUrn = `urn:li:person:${personUrn}`;
|
|
|
|
} else {
|
|
|
|
const organizationUrn = this.getNodeParameter('organization', i) as string;
|
|
|
|
authorUrn = `urn:li:organization:${organizationUrn}`;
|
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
let description = '';
|
|
|
|
let title = '';
|
|
|
|
let originalUrl = '';
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2023-03-31 06:04:43 -07:00
|
|
|
body = {
|
|
|
|
author: authorUrn,
|
|
|
|
lifecycleState: 'PUBLISHED',
|
|
|
|
distribution: {
|
|
|
|
feedDistribution: 'MAIN_FEED',
|
|
|
|
thirdPartyDistributionChannels: [],
|
|
|
|
},
|
|
|
|
visibility,
|
|
|
|
};
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (shareMediaCategory === 'IMAGE') {
|
|
|
|
if (additionalFields.title) {
|
|
|
|
title = additionalFields.title as string;
|
|
|
|
}
|
|
|
|
// Send a REQUEST to prepare a register of a media image file
|
|
|
|
const registerRequest = {
|
2023-03-31 06:04:43 -07:00
|
|
|
initializeUploadRequest: {
|
2021-07-19 23:58:54 -07:00
|
|
|
owner: authorUrn,
|
|
|
|
},
|
|
|
|
};
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
const registerObject = await linkedInApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
2023-03-31 06:04:43 -07:00
|
|
|
'/images?action=initializeUpload',
|
2022-08-17 08:50:24 -07:00
|
|
|
registerRequest,
|
|
|
|
);
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2023-03-06 08:33:32 -08:00
|
|
|
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
2024-05-08 02:23:08 -07:00
|
|
|
const imageMetadata = this.helpers.assertBinaryData(i, binaryPropertyName);
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2023-03-06 08:33:32 -08:00
|
|
|
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
2023-03-31 06:04:43 -07:00
|
|
|
const { uploadUrl, image } = registerObject.value;
|
2024-05-08 02:23:08 -07:00
|
|
|
|
|
|
|
const headers = {};
|
|
|
|
Object.assign(headers, { 'Content-Type': imageMetadata.mimeType });
|
|
|
|
|
|
|
|
await linkedInApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
uploadUrl as string,
|
|
|
|
buffer,
|
|
|
|
true,
|
|
|
|
headers,
|
|
|
|
);
|
2023-03-31 06:04:43 -07:00
|
|
|
|
|
|
|
const imageBody = {
|
|
|
|
content: {
|
|
|
|
media: {
|
|
|
|
title,
|
|
|
|
id: image,
|
2021-07-19 23:58:54 -07:00
|
|
|
},
|
|
|
|
},
|
2023-03-31 06:04:43 -07:00
|
|
|
commentary: text,
|
2021-07-19 23:58:54 -07:00
|
|
|
};
|
2023-03-31 06:04:43 -07:00
|
|
|
Object.assign(body, imageBody);
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (shareMediaCategory === 'ARTICLE') {
|
|
|
|
if (additionalFields.description) {
|
|
|
|
description = additionalFields.description as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.title) {
|
|
|
|
title = additionalFields.title as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.originalUrl) {
|
|
|
|
originalUrl = additionalFields.originalUrl as string;
|
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2023-03-31 06:04:43 -07:00
|
|
|
const articleBody = {
|
|
|
|
content: {
|
|
|
|
article: {
|
|
|
|
title,
|
|
|
|
description,
|
|
|
|
source: originalUrl,
|
2021-07-19 23:58:54 -07:00
|
|
|
},
|
|
|
|
},
|
2023-03-31 06:04:43 -07:00
|
|
|
commentary: text,
|
2021-07-19 23:58:54 -07:00
|
|
|
};
|
2023-11-03 02:50:28 -07:00
|
|
|
|
|
|
|
if (additionalFields.thumbnailBinaryPropertyName) {
|
|
|
|
const registerRequest = {
|
|
|
|
initializeUploadRequest: {
|
|
|
|
owner: authorUrn,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const registerObject = await linkedInApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
'/images?action=initializeUpload',
|
|
|
|
registerRequest,
|
|
|
|
);
|
|
|
|
|
|
|
|
const binaryPropertyName = additionalFields.thumbnailBinaryPropertyName as string;
|
2024-05-08 02:23:08 -07:00
|
|
|
const imageMetadata = this.helpers.assertBinaryData(i, binaryPropertyName);
|
2023-11-03 02:50:28 -07:00
|
|
|
|
|
|
|
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
|
|
const { uploadUrl, image } = registerObject.value;
|
2024-05-08 02:23:08 -07:00
|
|
|
|
|
|
|
const headers = {};
|
|
|
|
Object.assign(headers, { 'Content-Type': imageMetadata.mimeType });
|
|
|
|
|
|
|
|
await linkedInApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
uploadUrl as string,
|
|
|
|
buffer,
|
|
|
|
true,
|
|
|
|
headers,
|
|
|
|
);
|
2023-11-03 02:50:28 -07:00
|
|
|
Object.assign(articleBody.content.article, { thumbnail: image });
|
|
|
|
}
|
|
|
|
|
2023-03-31 06:04:43 -07:00
|
|
|
Object.assign(body, articleBody);
|
2022-06-23 14:15:29 -07:00
|
|
|
if (description === '') {
|
2023-03-31 06:04:43 -07:00
|
|
|
delete body.description;
|
2022-06-23 14:15:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (title === '') {
|
2023-03-31 06:04:43 -07:00
|
|
|
delete body.title;
|
2022-06-23 14:15:29 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2023-03-31 06:04:43 -07:00
|
|
|
Object.assign(body, { commentary: text });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
2023-03-31 06:04:43 -07:00
|
|
|
const endpoint = '/posts';
|
2021-07-19 23:58:54 -07:00
|
|
|
responseData = await linkedInApiRequest.call(this, 'POST', endpoint, body);
|
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
}
|
2023-01-31 11:39:20 -08:00
|
|
|
const executionData = this.helpers.constructExecutionMetaData(
|
2023-02-27 19:39:43 -08:00
|
|
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
2023-01-31 11:39:20 -08:00
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
|
|
|
returnData.push(...executionData);
|
2021-07-19 23:58:54 -07:00
|
|
|
} catch (error) {
|
2024-06-19 22:45:00 -07:00
|
|
|
if (this.continueOnFail(error)) {
|
2023-01-31 11:39:20 -08:00
|
|
|
const executionData = this.helpers.constructExecutionMetaData(
|
|
|
|
this.helpers.returnJsonArray({ error: error.message }),
|
|
|
|
{ itemData: { item: i } },
|
|
|
|
);
|
|
|
|
returnData.push(...executionData);
|
2021-07-19 23:58:54 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
throw error;
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-05 03:59:02 -07:00
|
|
|
return [returnData];
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
}
|
|
|
|
}
|