2015-09-07 38 views
0

我想要從名爲getProfileData的函數獲取名爲data的LinkedIn API返回的數據。我如何訪問包含firstNamelastName之類信息的數據,而不是在getProfileData中,而不僅僅是功能onSuccess從LinkedIn SDK獲取LinkedIn返回的數據

<script type="text/javascript" src="//platform.linkedin.com/in.js"> 
    api_key: YOUR_API_KEY_HERE 
    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", 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); 
     // I want to see the profile data in here. 

    } 

</script> 

回答

0

您必須修復代碼中的東西:

IN.API.Raw("/people/~:(id,first-name,last-name,location,positions)?format=json").result(onSuccess).error(onError); 
+0

data.firstName,data.lastName中的onSuccess功能 – Sankar