我的任务是分享一个从页面链接的帖子。我已经浏览了文档中的链接,但我不明白该怎么做。 我已经用谷歌搜索了好几天,但我没有得到一个清晰的想法。
任何人都可以清楚地解释如何分享到 linkedin。我不想分享整个页面,只想分享特定的帖子。
这是我从网上得到的代码,但我不知道这段代码发生了什么。
<html>
<head>
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: xxxxxxxxx
authorize: true
onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
// Setup an event listener to make an API call once auth is complete
function onLinkedInLoad() {
IN.Event.on(IN, "auth", shareContent);
}
// 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);
}
// Use the API call wrapper to share content on LinkedIn
function shareContent() {
// Build the JSON payload containing the content to be shared
var payload = {
Content-Type: application/json
x-li-format: json
"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"
}
};
IN.API.Raw("/people/~/shares?format=json")
.method("POST")
.body(JSON.stringify(payload))
.result(onSuccess)
.error(onError);
}
</script>
</head>
<body>
<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share"></script>
</body>
</html>
除了代码,我还需要任何其他文件吗?
我在 codeigniter 工作。
请帮忙。
提前致谢。
最佳答案
我读了你的 javascript 代码,它实际上在做你想做的事,但我认为你应该用 php 或 nodejs 来做这件事,比如后端语言。
要执行此操作以及更多操作,您需要使用 Linked in 的 REST API。
所有 REST API 都具有相同的架构,首先您需要验证您的帐户,然后发送请求并获得响应(使用相同的 session )并执行您想要的操作。
编辑:我在 here 中找到了您想要的内容
关于javascript - 如何将帖子分享到 linkedin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34715114/