如何分享帖子到linkedin

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工作.

请帮忙.

提前致谢.

Meh*_*alp 1

我读了你的 javascript 代码,它实际上正在做你想做的事情,但我认为你应该用 php 或 Nodejs 等后端语言来做这件事。

要完成此操作以及更多操作,您需要使用 Linked in 的 REST API。
所有 REST API 都具有相同的架构,首先您需要验证您的帐户,然后发送请求并获取响应(使用相同的会话)并执行您想要的操作。

编辑:我在这里找到了你想要的东西