使用带RESTAPI的JavaScript检索LinkedIn配置文件图片

使用带RESTAPI的JavaScript检索LinkedIn配置文件图片,javascript,rest,oauth,linkedin,restful-authentication,Javascript,Rest,Oauth,Linkedin,Restful Authentication,我目前正在我的web应用程序上实现LinkedIn授权和登录功能,并使用LinkedIn JavaScript开发人员示例代码: <script type="text/javascript" src="//platform.linkedin.com/in.js"> api_key: YOUR_API_KEY_HERE authorize: true onLoad: onLinkedInLoad </script> <script type=

我目前正在我的web应用程序上实现LinkedIn授权和登录功能,并使用LinkedIn JavaScript开发人员示例代码:

<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);
    }

</script>

我从未使用过RESTAPI,因此我无法理解如何将此代码实现到现有的段中。如何使用现有的JS代码向REST API代码发出请求,以便prorgam可以获取文本数据和用户图像?

如果您只想检索配置文件图像,则不需要JSON格式的图像。只用

function onSuccess(data) {
     String imageUrl = "http://api.linkedin.com/v1/people/"+data.id+"/picture-url";
     //i.e. $("img").attr("src",imageUrl);
}

将{user id}替换为实际用户id。一旦通过授权方案,您就可以访问它。

如果您只想检索配置文件映像,则不需要JSON格式的映像。只用

function onSuccess(data) {
     String imageUrl = "http://api.linkedin.com/v1/people/"+data.id+"/picture-url";
     //i.e. $("img").attr("src",imageUrl);
}

将{user id}替换为实际的用户id。一旦通过授权方案,您就可以访问它。

向发出请求,它将返回一个包含json文件的结果,该文件带有图片。向此API发出的请求将如何写入?我知道它确实需要以请求的形式出现,我只是不知道要执行它的JS代码向它发出请求,它应该返回一个结果,其中包含一个带有图片的json文件。如何编写对该API的请求?我知道它确实需要以请求的形式出现,我只是不知道用JS代码来实现它