2015-09-25 22 views
1

我正在做一個網站的第一次。我爲任何愚蠢的問題感到抱歉,但我真的沒有背景。不過,我正在努力學習。 我在Weebly開發了網站(www.i2i.network),我試圖通過他們的API服務包含一個LinkedIn SignUp按鈕來監控使用該網站的人。Linkedin API SignUp按鈕 - 我是一個初學者

到目前爲止,我複製並粘貼什麼,我已經在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服務,如果「是」如何管理它們,並可能包括他們在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: "[email protected]", // 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> 

我知道這可能是一個很基本的問題,但我從零開始,我喜歡通過實踐來學習......

此外,如果您有關於網站或教程任何建議,我可以一步一步學習它將非常感激。

感謝你的幫助,

賈科莫

+0

如果你的代碼工作正常,按鈕點擊事件已觸發後,招聘人員就會出現。 – snowYetis

+0

@snowYetis:你能更具體嗎?什麼是招聘人員?一個例子會很有用。 :S –

+0

我的第一個評論是一個笑話。您以前使用過瀏覽器DevTools嗎?啓動您的網頁並點擊F12。接下來,點擊LinkedIn提交按鈕,看看是否有任何內容出現在控制檯標籤中。 – snowYetis

回答

0

仔細檢查語法,但這應該讓你開始。

// 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腳本文件,並引用它在其他頁面,但你必須保持加入到這個腳本任何控件ID /類名,文件相同,所以我的建議是保持這個文件非常通用,以便它不依賴於其他任何內容,只處理LinkedIn數據。

我推薦這些鏈接進一步閱讀,以便您可以擴展您的代碼。

Jquery Parse JSON

JQuery AJAX

JQuery Callbacks

+0

感謝您的幫助 –