无法使用LinkedIn API v在LinkedIn上共享。2.
我很难在LinkedIn上获得共享。我正试图通过LinkedIn API V2发布LinkedIn共享,每次我发出post请求时,服务器都会给出请求超时(状态504)的答复。这是我的密码:无法使用LinkedIn API v在LinkedIn上共享。2.,linkedin,linkedin-api,Linkedin,Linkedin Api,我很难在LinkedIn上获得共享。我正试图通过LinkedIn API V2发布LinkedIn共享,每次我发出post请求时,服务器都会给出请求超时(状态504)的答复。这是我的密码: myPost = { 'author': 'urn:li:person:' + this.uid, 'lifecycleState': 'PUBLISHED', 'specificContent': { 'com.linkedin.ugc.ShareCo
myPost = {
'author': 'urn:li:person:' + this.uid,
'lifecycleState': 'PUBLISHED',
'specificContent': {
'com.linkedin.ugc.ShareContent': {
'shareCommentary': {
'text': 'Hello World! This is my first Share on LinkedIn!'
},
'shareMediaCategory': 'NONE'
}
},
'visibility': {
'com.linkedin.ugc.MemberNetworkVisibility': 'PUBLIC'
}
}
header = {
'Content-Type': 'application/json',
'X-Restli-Protocol-Version': '2.0.0',
'Authorization': 'Bearer ' + token
};
this.http.post('https://api.linkedin.com/v2/ugcPosts', myPost, header).then(res => {
alert(JSON.stringify(res));
})
.catch(err => {
alert(JSON.stringify(err));
});
下面是错误消息:
{
"message": "Request timed out",
"status": 504
}
这是一个angular ionic项目,我使用本机cordova插件advanced http发出post请求。我在使用LinkedIn登录、获取访问令牌以及使用相同的本地插件和LinkedIn API V2从LinkedIn检索数据方面没有问题
在我的LinkedIn开发人员帐户上,在使用和限制页面,我可以看到创建方法的API调用。对我在python上的相同问题也有帮助
head = {
'Authorization': 'Bearer '+token, 'X-Restli-Protocol-Version': '2.0.0'
}
body = {
"author": 'urn:li:person:'+ID,
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Hello World! This is my first Share on LinkedIn!"
},
"shareMediaCategory": "NONE"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
requests.post('https://api.linkedin.com/v2/ugcPosts', data=json.dumps(body),headers=head)
如果LinkedIn无法解析请求正文,则LinkedIn API v2中与POST端点相关的超时可能会发生。这里发布的示例的解决方案是将
myPost
转换为正确的JSON字符串,例如JSON.dumps(myPost)
如果缺少
'Content-Type':'application/json'
头,也会发生超时。在使用ruby玩他们的API时,头刚好咬了我一口。真的没有理由使用模糊的js-lib插件来共享LinkedIn上的链接。您所需要的只是:
https://www.linkedin.com/sharing/share-offsite/?url={url}
来源:
例如,这对我很有用:
工作正常:
根本没有身份验证问题。然后只需制作自己的按钮并将其超链接即可。没问题
如果你对一个定期维护的GitHub项目感兴趣,可以跟踪它,这样你就不必这么做了,去看看吧
嗨,欢迎来到StackOverflow!如果你包括了你已经尝试过的东西以及它如何不符合你的需要,那么得到答案通常是有帮助的。另外,有关您尝试执行共享时收到的错误消息的详细信息将有助于诊断问题。如果您仍然遇到超时问题,请向linkedin.zendesk.com提交一份通知单,并包括从您的POST请求中收到的响应标题。我收到了此问题“将请求正文解析为json时出错非法的无引号字符((CTRL-CHAR,代码10)):必须使用反斜杠进行转义才能包含在字符串值中\n在[Source:(com.linkedin.data.ByteString$ByteArrayVectorInputStream);第7行,第249列]“当我的帖子有“-”时。”。