Skip to content

Instantly share code, notes, and snippets.

@miguelsaddress
Created May 26, 2017 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelsaddress/9e1a7fe0c6cad5e960bb249ec03ca829 to your computer and use it in GitHub Desktop.
Save miguelsaddress/9e1a7fe0c6cad5e960bb249ec03ca829 to your computer and use it in GitHub Desktop.
Fetching Public User info from Github with Github4s
name := "GitHub4S Test"
version := "1.0"
scalaVersion := "2.12.2"
libraryDependencies += "com.47deg" %% "github4s" % "0.15.0"
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.Await
import github4s.Github
import github4s.Github._
import github4s.GithubResponses.GHResult
import github4s.jvm.Implicits._
import scalaj.http.HttpResponse
object Main extends App {
val accessToken = Some("yourTokenHere") // not needed for public calls
val request = Github(None).users.get("miguelsaddress").execFuture[HttpResponse[String]]()
request.foreach { response =>
response match {
case Right(GHResult(result, status, headers)) => println(result)
case Left(e) => println(e.getMessage)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment