Skip to content

Async Scala SDK for the Facebook Graph API, built on spray-client and spray-json.

Notifications You must be signed in to change notification settings

almeidap/spracebook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spracebook is a native Scala SDK that provides asynchronous access to the Facebook Graph API. It is built heavily on spray-client for async non-blocking HTTP I/O and spray-json for parsing JSON responses into Scala case classes.

While Spracebook is in production use at Pongr, it currently uses many proof-of-concept ideas and will most likely undergo heavy changes in the future. Thus, it's currently only at a 0.1 state. We would love to hear any feedback you have on the approach Spracebook takes to provide an async native Scala SDK experience for a REST web service. We will also be releasing similar libraries for Instagram, Twitter, etc in the future based on these ideas.

sbt

Spracebook releases are in the central Maven repository. Snapshots are in https://oss.sonatype.org/content/repositories/snapshots/.

"com.pongr" %% "spracebook" % "0.1.0-SNAPSHOT"

Usage

The Facebook Graph API is represented as a trait; each action that can be performed on a resource is represented as a function in this trait. Each function returns a Future of the response from the Graph API, parsed into a convenient case class.

//setup
implicit val system = ActorSystem()
val ioBridge = IOExtension(system).ioBridge()
val httpClient = system.actorOf(Props(new HttpClient(ioBridge)))
val facebookApiConduit = system.actorOf(
  props = Props(new HttpConduit(httpClient, "graph.facebook.com", 443, sslEnabled = true)),
  name = "facebook-api-conduit"
)
val facebook = new SprayClientFacebookGraphApi(facebookApiConduit)

//examples
val token: String = ???
val user: Future[User] = facebook.getUser(token)
val friends: Future[Seq[User]] = facebook.getFriends(token)
val event: Future[CreatedComment] = facebook.createComment(photoId, "That is totally rad!", token)

License

Spracebook is released under the Apache 2 License.

Credits

Authors

About

Async Scala SDK for the Facebook Graph API, built on spray-client and spray-json.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published