我的任务是分享从页面链接到的帖子。我已经完成了文档中的链接,但我无法理解该怎么做。 我用谷歌搜索了几天,但我没有明确的想法。
任何人都可以清楚地解释如何分享到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工作。
请帮忙。
提前致谢。
答案 0 :(得分:0)
我读了你的javascript代码,它实际上是你想做的,但我认为你应该在php或者像后端语言这样的nodejs中做这件事。
要做到这一点,还需要使用Linked in REST API
所有REST API都具有相同的体系结构,首先需要验证您的帐户,然后发送请求并获得响应(使用相同的会话)并执行您想要的操作。
编辑:我在here
中找到了您想要的内容