linkedin - Linkedin SDK for Scala.js
Linkedin SDK for Scala.js
$ sbt clean publish-local
Before running the tests the first time, you must ensure the npm packages are installed:
$ npm install
Then you can run the tests:
$ sbt test
Inside of your HTML index page:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [YOUR_API_KEY_GOES_HERE]
authorize: true
onLoad: linkedInInit
scope: r_basicprofile r_emailaddress rw_company_admin w_share
</script>
Within your Scala.js application:
import io.scalajs.social.linkedin._
import scalajs.js
js.Dynamic.global.linkedInInit = () => {
val injector = angular.element(jQuery("#Main")).injector()
injector.get[MySessionService]("MySession").toOption match {
case Some(mySession) =>
console.info("Initializing LinkedIn API...")
mySession.initLinkedIn(LinkedIn.IN)
case None =>
console.error("MySession could not be retrieved.")
}
}
Afterwards, you may call any LinkedIn API that you have the permissions to execute:
import io.scalajs.social.linkedin._
import scalajs.js
var linkedInID: js.UndefOr[String] = js.undefined
// read the authenticated user's profile
IN.API.Profile(js.Array("me")) onComplete {
case Success(response) =>
linkedInID = response.values.headOption.flatMap(_.id.toOption).orUndefined
case Failure(e) =>
console.error(s"Failed to retrieve LinkedIn profile - ${e.getMessage}")
}
To add the Linkedin
binding to your project, add the following to your build.sbt:
libraryDependencies += "io.scalajs" %%% "linkedin-api" % "0.5.0"
Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")