如何生成链接组加入按钮

时间:2014-03-27 07:57:13

标签: linkedin jsapi

有谁知道如何生成linkedin组按钮?我想要做的是显示用户加入的组列表。

像这样:

Group 1     <button> join </button>
Group 2     <button> join </button>
Group 3     <button> join </button> 

我不了解群组API的文档https://developer.linkedin.com/documents/groups-api#membergroups。 我如何在JSAPI中进行PUT / POST?以及如何格式化帖子数据?有人可以帮我弄这个吗?提前谢谢!

1 个答案:

答案 0 :(得分:0)

...更新

这可以在JS API中使用吗?

JSAPI可以在这里找到不同的方法。 https://developer.linkedin.com/documents/inapiraw

我尝试了下面的脚本,但它没有用。

var grp = {
        "group-membership": {
                "group": {
                    "id": 11234555 
                },
                "show-group-logo-in-profile": true,
                "email-digest-frequency": {
                    "code": "daily"
                },
                "email-announcements-from-managers": true,
                "allow-messages-from-members": true,
                "email-for-every-new-post": false,
                "membership-state": {
                    "code": "member"
                }
            }
    }


IN.API.Raw('/people/~/group-memberships').method('POST').body(JSON.stringify(grp)).result(function(a){
    console.log(a);
});

回应:

  {
  "errorCode": 0,
  "message": "Invalid xml {Expected elements 'group@http://api.linkedin.com/v1 membership-state@http://api.linkedin.com/v1 contact-email@http://api.linkedin.com/v1 show-group-logo-in-profile@http://api.linkedin.com/v1 allow-messages-from-members@http://api.linkedin.com/v1 email-digest-frequency@http://api.linkedin.com/v1 email-announcements-from-managers@http://api.linkedin.com/v1 email-for-every-new-post@http://api.linkedin.com/v1' instead of 'group-membership@http://api.linkedin.com/v1' here in element group-membership@http://api.linkedin.com/v1}",
  "requestId": "5FX3EI2PEU",
  "status": 400,
  "timestamp": 1395909893090
}

使用XML

xmlbody = '<?xml version="1.0" encoding="UTF-8"?>  <group-membership>  <group>
     <id>G11234555</id>   </group>    <show-group-logo-in-profile>true</show-group-logo-in-profile> <email-digest-frequency>
     <code>daily</code>    </email-digest-frequency>    <email-announcements-from-managers>true</email-announcements-from-managers> <allow-messages-from-members>true</allow-messages-from-members>  <email-for-every-new-post>false</email-for-every-new-post>  <membership-state>
     <code>member</code>    </membership-state>  </group-membership> ';
                 IN.API.Raw('/people/~/group-memberships').method('POST').body(xmlbody).result(function(a){ console.log(a);     });

回应:

  

{&#34; errorCode&#34;:0,&#34; message&#34;:&#34;无法解析Json正文:意外   字符(&#39;&lt;&#39;(代码60)):预期有效值(数字,字符串,   数组,对象,&#39; true&#39;,&#39; false&#39;或者&#39; null&#39;)\ n在[来源:   java.io.StringReader@27418295; line:1,column:2]&#34;,&#34; requestId&#34;:   &#34; JFGI4LRP2C&#34;,&#34; status&#34;:400,&#34; timestamp&#34;:1395970257979}