LinkedIn 分享 API 返回 "Bad Request" 错误
LinkedIn Share API returning "Bad Request" error
我正在尝试实现 LinkedIn 共享 API,但我无法弄清楚这一点,因为回复并没有真正说明发生了什么。
我已经在我的网站上实现了这个简单的代码
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: xxx
authorize: true
lang: de_DE
</script>
<script type="text/javascript">
// Handle the successful return from the API call
function onSuccess(data) {
console.log(data);
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
function shareToLinkedIn(){
var payload = {
"content": {
"title": "Test title",
"description": "test description",
"submitted-url": "http://www.someurl.com",
"submitted-image-url": "http://someurl.com/somepic.png"
},
"visibility": {
"code": "connections-only"
}
};
IN.API.Raw("/people/~/shares?format=json")
.method("POST")
.body(JSON.stringify(payload))
.result(onSuccess)
.error(onError);
}
</script>
我通过 onClick 事件调用此函数:
<a id="linkedin" href="#"onClick="shareToLinkedIn()"><i class="fa fa-linkedin-square" aria-hidden="true"></i> LinkedIn Test</a></li>
但我得到的只是以下响应:Object {errorCode: 0, message: "Invalid arguments: {S_400_BAD_REQUEST=Bad request}", requestId: "4JVTZJFVF1", status: 400, timestamp: 1467381898243}
对此的回答:您还需要在您的网站上实现一个登录按钮,仅仅登录到 LinkedIn 网站是不够的。
因此,在实施 "share app" 的网站上,添加:
<script type="in/Login"></script>
之后,点击按钮,授权应用程序,它应该可以运行。
你知道吗,其实根本不用分享插件也能解决这个问题。其实只要看看LinkedIn Developers Homepage: "Share on LinkedIn" link. It no longer goes to the old LinkedIn documentation, which has broken styles, broken js, broken HTML, and missing images. It redirects to the Microsoft LinkedIn Share URL Documentation就可以了。如果 LinkedIn 共享插件没有被弃用,它肯定不会出现!
您可以完全放弃 LinkedIn 共享插件。根据 Microsoft LinkedIn 文档,您只需要以下内容...
https://www.linkedin.com/sharing/share-offsite/?url={url}
希望您知道这些 URL 的变化和演变,而不必自己去追踪它们?我在 GitHub 上维护一个项目来做到这一点。检查我们! Social Share URLs
我正在尝试实现 LinkedIn 共享 API,但我无法弄清楚这一点,因为回复并没有真正说明发生了什么。
我已经在我的网站上实现了这个简单的代码
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: xxx
authorize: true
lang: de_DE
</script>
<script type="text/javascript">
// Handle the successful return from the API call
function onSuccess(data) {
console.log(data);
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
function shareToLinkedIn(){
var payload = {
"content": {
"title": "Test title",
"description": "test description",
"submitted-url": "http://www.someurl.com",
"submitted-image-url": "http://someurl.com/somepic.png"
},
"visibility": {
"code": "connections-only"
}
};
IN.API.Raw("/people/~/shares?format=json")
.method("POST")
.body(JSON.stringify(payload))
.result(onSuccess)
.error(onError);
}
</script>
我通过 onClick 事件调用此函数:
<a id="linkedin" href="#"onClick="shareToLinkedIn()"><i class="fa fa-linkedin-square" aria-hidden="true"></i> LinkedIn Test</a></li>
但我得到的只是以下响应:Object {errorCode: 0, message: "Invalid arguments: {S_400_BAD_REQUEST=Bad request}", requestId: "4JVTZJFVF1", status: 400, timestamp: 1467381898243}
对此的回答:您还需要在您的网站上实现一个登录按钮,仅仅登录到 LinkedIn 网站是不够的。 因此,在实施 "share app" 的网站上,添加:
<script type="in/Login"></script>
之后,点击按钮,授权应用程序,它应该可以运行。
你知道吗,其实根本不用分享插件也能解决这个问题。其实只要看看LinkedIn Developers Homepage: "Share on LinkedIn" link. It no longer goes to the old LinkedIn documentation, which has broken styles, broken js, broken HTML, and missing images. It redirects to the Microsoft LinkedIn Share URL Documentation就可以了。如果 LinkedIn 共享插件没有被弃用,它肯定不会出现!
您可以完全放弃 LinkedIn 共享插件。根据 Microsoft LinkedIn 文档,您只需要以下内容...
https://www.linkedin.com/sharing/share-offsite/?url={url}
希望您知道这些 URL 的变化和演变,而不必自己去追踪它们?我在 GitHub 上维护一个项目来做到这一点。检查我们! Social Share URLs