type Linkedin = {
token: string;
};
export async function main(
auth: Linkedin,
content: string,
visibility: "PUBLIC" | "CONNECTIONS" = "PUBLIC",
) {
const entityResponse = await fetch("https://api.linkedin.com/v2/me", {
headers: { Authorization: "Bearer " + auth.token },
});
const entityId = (await entityResponse.json()).id;
const url = new URL("https://api.linkedin.com/v2/ugcPosts");
const body = JSON.stringify({
author: `urn:li:person:${entityId}`,
lifecycleState: "PUBLISHED",
specificContent: {
"com.linkedin.ugc.ShareContent": {
shareCommentary: {
text: content,
},
shareMediaCategory: "NONE",
},
},
visibility: {
"com.linkedin.ugc.MemberNetworkVisibility": visibility,
},
});
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
"X-Restli-Protocol-Version": "2.0.0",
},
body,
});
if (!response.ok) {
throw Error(await response.text());
}
return await response.json();
}
Submitted by admin 466 days ago
type Linkedin = {
token: string;
};
export async function main(
auth: Linkedin,
content: string,
visibility: 'PUBLIC' | 'CONNECTIONS' = 'PUBLIC'
) {
const entityResponse = await fetch('https://api.linkedin.com/v2/me', {
headers: { Authorization: "Bearer " + auth.token },
})
const entityId = (await entityResponse.json()).id
const url = new URL('https://api.linkedin.com/v2/ugcPosts')
const body = JSON.stringify({
author: `urn:li:person:${entityId}`,
lifecycleState: 'PUBLISHED',
specificContent: {
'com.linkedin.ugc.ShareContent': {
shareCommentary: {
text: content
},
shareMediaCategory: 'NONE'
}
},
visibility: {
'com.linkedin.ugc.MemberNetworkVisibility': visibility
}
})
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
'X-Restli-Protocol-Version': '2.0.0'
},
body
})
if(!response.ok) {
throw Error(await response.text())
}
return await response.json()
}
Submitted by admin 470 days ago
import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts"
export async function main(
auth: wmill.Resource<'linkedin'>,
content: string,
visibility: 'PUBLIC' | 'CONNECTIONS' = 'PUBLIC'
) {
const entityResponse = await fetch('https://api.linkedin.com/v2/me', {
headers: { Authorization: "Bearer " + auth.token },
})
const entityId = (await entityResponse.json()).id
const url = new URL('https://api.linkedin.com/v2/ugcPosts')
const body = JSON.stringify({
author: `urn:li:person:${entityId}`,
lifecycleState: 'PUBLISHED',
specificContent: {
'com.linkedin.ugc.ShareContent': {
shareCommentary: {
text: content
},
shareMediaCategory: 'NONE'
}
},
visibility: {
'com.linkedin.ugc.MemberNetworkVisibility': visibility
}
})
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
'X-Restli-Protocol-Version': '2.0.0'
},
body
})
if(!response.ok) {
throw Error(await response.text())
}
return await response.json()
}
Submitted by adam186 598 days ago
import * as wmill from "https://deno.land/x/windmill@v1.70.1/mod.ts"
export async function main(
auth: wmill.Resource<'linkedin'>,
content: string,
visibility: 'PUBLIC' | 'CONNECTIONS' = 'PUBLIC'
) {
const entityResponse = await fetch('https://api.linkedin.com/v2/me', {
headers: { Authorization: "Bearer " + auth.token },
})
const entityId = (await entityResponse.json()).id
const url = new URL('https://api.linkedin.com/v2/ugcPosts')
const body = JSON.stringify({
author: `urn:li:person:${entityId}`,
lifecycleState: 'PUBLISHED',
specificContent: {
'com.linkedin.ugc.ShareContent': {
shareCommentary: {
text: content
},
shareMediaCategory: 'NONE'
}
},
visibility: {
'com.linkedin.ugc.MemberNetworkVisibility': visibility
}
})
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
'X-Restli-Protocol-Version': '2.0.0'
},
body
})
if(!response.ok) {
throw Error(await response.text())
}
return await response.json()
}
Submitted by adam186 633 days ago
import * as wmill from "https://deno.land/x/windmill@v1.55.0/mod.ts"
export async function main(
auth: wmill.Resource<'linkedin'>,
content: string,
visibility: 'PUBLIC' | 'CONNECTIONS' = 'PUBLIC'
) {
const entityResponse = await fetch('https://api.linkedin.com/v2/me', {
headers: { Authorization: "Bearer " + auth.token },
})
const entityId = (await entityResponse.json()).id
const url = new URL('https://api.linkedin.com/v2/ugcPosts')
const body = JSON.stringify({
author: `urn:li:person:${entityId}`,
lifecycleState: 'PUBLISHED',
specificContent: {
'com.linkedin.ugc.ShareContent': {
shareCommentary: {
text: content
},
shareMediaCategory: 'NONE'
}
},
visibility: {
'com.linkedin.ugc.MemberNetworkVisibility': visibility
}
})
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
'X-Restli-Protocol-Version': '2.0.0'
},
body
})
if(!response.ok) {
throw Error(await response.text())
}
return await response.json()
}
Submitted by adam186 713 days ago