type Linkedin = {
token: string
apiVersion: string
}
export async function main(
resource: Linkedin,
activityUrn: string, // can be either Share/Post/Comment Urn
likeData: {
actor: string
object: string
}
) {
// Using unversioned API, can replace with versioned one, but cannot test without Marketing access.
const endcodedActivityUrn = encodeURIComponent(activityUrn)
const endpoint = `https://api.linkedin.com/v2/socialActions/${endcodedActivityUrn}/likes`
const response = await fetch(endpoint, {
method: 'POST',
headers: {
Authorization: `Bearer ${resource.token}`,
'X-Restli-Protocol-Version': '2.0.0',
'Content-Type': 'application/json'
},
body: JSON.stringify(likeData)
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
return data
}
Submitted by hugo697 130 days ago
type Linkedin = {
token: string
apiVersion: string
}
export async function main(
resource: Linkedin,
activityUrn: string, // can be either Share/Post/Comment Urn
likeData: {
actor: string
object: string
}
) {
// Using unversioned API, can replace with versioned one, but cannot test without Marketing access.
const endcodedActivityUrn = encodeURIComponent(activityUrn)
const endpoint = `https://api.linkedin.com/v2/socialActions/${endcodedActivityUrn}/likes`
const response = await fetch(endpoint, {
method: 'POST',
headers: {
Authorization: `Bearer ${resource.token}`,
'X-Restli-Protocol-Version': '2.0.0',
'Content-Type': 'application/json'
},
body: JSON.stringify(likeData)
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
return data
}
Submitted by hugo697 130 days ago