Linkedin API 注册按钮 - 我是初学者

Linkedin API SignUp Button - I am a beginner

我是第一次做网站。对于任何愚蠢的问题,我深表歉意,但我真的没有背景。但是,我正在努力学习。 我在 Weebly (www.i2i.network) 上开发了这个网站,我试图通过他们的 API 服务包含一个 LinkedIn 注册按钮来监控使用该网站的人。

到目前为止,我复制并粘贴了我在 LinkedIn SDK 指南上找到的内容

<script type="in/Login"></script>

<script type="text/javascript" src="//platform.linkedin.com/in.js">
    IN.User.logout(callbackFunction, callbackScope);
    api_key:   [API] //I put my API key here 
    authorize: true
    onLoad: onLinkedInLoad
    lang:      [LANG_LOCALE]
</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", getProfileData);
    }

    // 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 request the member's basic profile data
    function getProfileData() {
        IN.API.Raw("/people/~").result(onSuccess).error(onError);
    }

</script>

该按钮第一次出现,它打开了与我的 LinkedIn 个人资料的连接。真令人兴奋! :D(极客)

此时我仍然不知道我是否从 LinkedIn API 服务中检索任何数据以及是否 "yes" 如何管理它们并可能将它们包含在 Intercom.io 中。

据我所知,我应该从 LinkedIn API 收到以下内容:

{
  "firstName": "Frodo",
  "headline": "Jewelery Repossession in Middle Earth",
  "id": "1R2RtA",
  "lastName": "Baggins",
  "siteStandardProfileRequest": {
    "url": "https://www.linkedin.com/profile/view?id=…"
  }
}

我真的收到回复了吗?我如何阅读它?如何在以下 Intercom.io 脚本中使用它?

<script>
  window.intercomSettings = {
    app_id: "k9sz4pfb",
    name: "Nikola Tesla", // Full name
    email: "nikola@example.com", // Email address
    created_at: 1312182000 // Signup date as a Unix timestamp
  };
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/k92zopfb';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>

我知道这可能是一个非常基本的问题,但我是从零开始的,我喜欢通过实践来学习...

此外,如果您对我可以逐步学习的网站或教程有任何建议,我们将不胜感激。

感谢您的帮助,

贾科莫

仔细检查语法,但这应该让你开始。

// Use the API call wrapper to request the member's basic profile data
 function getProfileData() {
    var dataOutput = 


      // I added the callback event DONE. This assures the data method is called when the this API call is successful and complete.
     var dataOutput =    IN.API.Raw("/people/~").result(onSuccess).error(onError).done( {

       if (dataOutput != null) {
          DoSomethingWithYourData(dataOutput);
       }
    });

 }

  function DoSomethingWithYourData(dataOutput) {
    console.log(dataOutput);
    // Parse your data or assign it to a control. do whatever here.
 }

为了回答您的其他问题,您可以将其添加到 JS 脚本文件并在其他页面上引用它,但是您必须保持添加到该脚本文件的任何控件 IDs/class 名称相同,所以我的建议是让这个文件非常通用,这样它就不依赖于任何其他东西,只处理 LinkedIn 的数据。

我推荐这些链接以供进一步阅读,以便您可以扩展您的代码。

Jquery Parse JSON

JQuery AJAX

JQuery Callbacks