我想通过request
NodeJS 包中的API与 LinkedIn 分享内容:
Request({
'method': 'POST',
'url': 'https://api.linkedin.com/v1/people/~/shares',
'headers': {
'content-type': 'application/json',
'x-li-format': 'json',
'authorization': 'Bearer' + this.accessToken
},
'qs': {
'format': 'json',
'content': {
'title': 'My title',
'description': 'One description',
'submitted-url': 'https://www.google.com/'
},
'comment': 'testing',
'visibility': {
'code': 'anyone'
}
}
}, callback)
执行此代码时出现此错误:无法解析JSON共享文档。
答案 0 :(得分:0)
将您的Json数据放入JSON.stringify(数据),然后发送,如:
var jsonBody = {
"comment": "Check out developer.linkedin.com!",
"content": {
"title": "LinkedIn Developers Resources",
"description": "Leverage LinkedIn's APIs to maximize engagement",
"submitted-url": "https://developer.linkedin.com",
"submitted-image-url": "https://example.com/logo.png"
},
"visibility": {
"code": "anyone"
}
}
body:JSON.stringify(jsonBody)
},回调)