我在使用 LinkedIn 分享时出现错误 API
I get an error when I use LinkedIn share API
我想在 LinkedIn 上与来自 request
NodeJS 包的 API 分享一些东西:
我的代码:
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 共享文档。
将您的 Json 数据放入 JSON.stringify(data) 然后发送,例如:
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)
}, 回调)
我想在 LinkedIn 上与来自 request
NodeJS 包的 API 分享一些东西:
我的代码:
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 共享文档。
将您的 Json 数据放入 JSON.stringify(data) 然后发送,例如:
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)
}, 回调)