0

I have a personal blog and I want to populate the "about me" section with my Linkedin data.

What's the best way to programmatically login to Linkedin with my own credentials and serve up the data?

I don't want vistors having to login to linkedin to be able to see "MY" linkedin data.

Any idea on the best approach for this?

This is the start of my code, I'm just starting out and getting an understanding of the flow.

(function($, window) {
"use strict";

var Linkedin = {
    Config: {
        API_KEY: "API_KEY",
        SECRET_KEY: "SECRET_KEY",
        URL: "http://www.hanger-designs.co.uk:8888/wemustcreate/",
        END_POINT: "http://platform.linkedin.com/in.js"
    },
    initalise: function() {
        this.insertScript(this.returnedFunc, this.Config.END_POINT);
    },
    insertScript: function(callback, endPoint) {
        var code = "api_key:" + this.Config.API_KEY + "\n" + 
                   "onLoad:" + callback + "\n" +
                   "authorize: true"
        var scriptElement = document.createElement('script');
        scriptElement.text = code;
        scriptElement.type = 'text/javascript';
        scriptElement.src = this.Config.END_POINT;

        document.body.appendChild(scriptElement);
    },
    returnedFunc: function() {
        console.log('callback', arguments);
    }

}

Linkedin.initalise();

})(jQuery, window);
0

1 Answer 1

1

To do this you need to authorize with OAuth. You blog can do this authorization (PHP/Perl/whatnot), but the clients cannot (JavaScript).

The reasons for this:

  • you are sharing the secret key, which can allow anyone access
  • you need to store state somewhere (the token). You should not store this on the client. You need a server in order to save the token.
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks Jonas, So in my callback I would start the OAuth journey? I can post to some PHP and handle it from there I suppose? I'd probably persist it within a cookie.
You could, but then why not move everything to PHP? :) If you have a database somewhere you can cache the linkedin info. I am sure linkedin has some sort of maximum limit of API calls. wordpress.org/extend/plugins/lips this plugin probably does some of the things you want to do.
Yes, I guess, I was just hoping I could handle most/all of it client side. But that's fine, I'll read up on the OAuth flow. Thanks
I tried to do client side authorization using githubs API. It works, but JavaScript just is not the right tool for the authorization part. Furthermore, the API has to support JSONP for you to access it cross-domain. Github's API does not and I have no reason to believe LinkedIn is any better. Good luck to you :)
@JonasG.Drange FYI, the LinkedIn API does support JSONP
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.