在核心中,我想通过他们的共享选项在用户的LinkedIn个人资料上发布/共享。但是我遇到两个错误:
jquery-3.4.1.min.js:2选项https://api.linkedin.com/v2/ugcPosts 401
和
从原点“ https://api.linkedin.com/v2/ugcPosts”到“ http://localhost:8080”处对XMLHttpRequest的访问已被CORS策略阻止:对预检请求的响应未通过访问控制检查:否'Access-Control-Allow-来源的标头出现在请求的资源上。
使用的代码是...(作为ajax调用)
function linkedInPost() {
$.ajax({
url: 'https://api.linkedin.com/v2/ugcPosts',
type: 'POST',
headers: 'X-Restli-Protocol-Version: 2.0.0',
/*beforeSend:{
'headers':'X-Restli-Protocol-Version: 2.0.0',
'Content-Type':'application/json'
},*/
data: {
"author": "urn:li:person:8675309",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Learning more about LinkedIn by reading the LinkedIn Blog!"
},
"shareMediaCategory": "ARTICLE",
"media": [{
"status": "READY",
"description": {
"text": "Official LinkedIn Blog - Your source for insights and information about LinkedIn."
},
"originalUrl": "https://blog.linkedin.com/",
"title": {
"text": "Official LinkedIn Blog"
}
}]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "CONNECTIONS"
}
},
success: function(data) {
console.log("success: ", data);
},
error: function(data) {
console.log("error: ", data)
}
})
}
有人可以帮我吗?