Abd*_*lla 6 javascript php json share linkedin
我的任务是分享从页面链接到的帖子.我已经完成了文档中的链接,但我无法理解该怎么做.我用谷歌搜索了几天,但我没有明确的想法.
任何人都可以清楚地解释如何分享到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>
Run Code Online (Sandbox Code Playgroud)
我是否需要任何其他文件以及代码?
我在codeigniter工作.
请帮忙.
提前致谢.