Giter Club home page Giter Club logo

linkedin-api's Introduction

linkedin-api GoDoc

NOTE:

This package is for the V1 API which has been deprecated and is pending removal. I don't currently have any plans on supporting V2, although that may change in the future. Any V2 support would be a major breaking change, and as such the state of the API would be subject to massive change, as well as dropping V1 support.

This project functions as a pure Go interface for Linkedin's v1 REST API. Currently, this provides a lightweight, documented interface to get a user's posts & profile data into a native marshallable Go struct. Requests are made secure by using OAuth2.0 authenticated requests to LinkedIn's servers.

This was my first project written in Go, and so I'd love to hear your thoughts!

This currently only supports GET requests.

Installation

go get -t github.com/johnaoss/linkedin-api

That's it!

Examples

I haven't tested this with other routing packages, but this does indeed work for any program using gorilla/mux for routing purposes.

Setting up the configurations

import api "github.com/johnaoss/linkedin-api"

func main() {
    permissions := []string{"r_basicprofile"}
    clientID := "myID"
    clientSecret := "hush"
    redirectURL := "https://example.com/totallyvalidauth"
    api.InitConfig(permissions, clientID, clientSecret, redirectURL)
}

Getting a user's login url (includes state)

import api "github.com/johnaoss/linkedin-api"

func loginHandler(w http.ResponseWriter, r *http.Request) {
    login := api.GetLoginURL(w,r)
    html := "Your login is <a href=\"" + login + "\">Login here!</a>"
    w.Write([]byte(html))
}

Getting a user's data

import api "github.com/johnaoss/linkedin-api"

// this handles the authorized redirect URL as specified in the Linkedin developer console
func authHandler(w http.ResponseWriter, r *http.Request) {
    userData := api.GetProfileData(w,r)
    html := "Your name is is " userData.FirstName + " " + userData.LastName
    w.Write([]byte(html))
}

Sharing a comment (UNTESTED)

import api "github.com/johnaoss/linkedin-api"

func sharePost(w http.ResponseWriter, r *http.Request) {
    vis := VisibilityStruct{Code: "anyone"}
    post := &api.Post{Visibility: vis, Comment: "This is a comment"}
    resp, err := api.SharePost(post,w,r)
    if err != nil {
        w.Write([]byte("Something went wrong!"))
    } else {
        w.Write([]byte("Your post was successfully shared!"))
    }
}

Limitations

This currently services only the non-partnered content as LinkedIn does not have any means of open-source developers to reliably acquire this data. Aside from that, if there are any bugs please feel free to get in touch with either an issue or an e-mail!

License

MIT Licensed, check the LICENSE.md file for more details.

TODO

  1. Proper testing of functions that require a router.
  2. POST features
  3. Full Linkedin Partner features (if possible)
  4. More info on current-share
  5. Clean up this code (was my first Go project after all)
  6. Work on v2 of this project!

linkedin-api's People

Contributors

johnaoss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

malnick

linkedin-api's Issues

provide full example

Hi,

Hope you are all well !

I would like to connect to the LinkedIn API and I am interested by your approach.
Can you provide a full example with the callback ?

That would be awesome if you could push a main.go example for a full test.

Cheers,
X

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.