fb-0.3: Bindings to Facebook's API.




FacebookT monad transformer

data FacebookT auth m a Source

FacebookT auth m a is this library's monad transformer. Contains information needed to issue commands and queries to Facebook. The phantom type auth may be either Auth (you have supplied your Credentials) or NoAuth (you have not supplied any Credentials).




:: Credentials

Your app's credentials.

-> Manager

Connection manager (see withManager).

-> FacebookT Auth m a 
-> m a 

Run a computation in the FacebookT monad transformer with your credentials.

runNoAuthFacebookT :: Manager -> FacebookT NoAuth m a -> m aSource

Run a computation in the FacebookT monad without credentials.

data Auth Source

Phantom type stating that you have provided your Credentials and thus have access to the whole API.


data NoAuth Source

Phantom type stating that you have not provided your Credentials. This means that you'll be limited about which APIs you'll be able use.


Authorization and Authentication


data Credentials Source

Credentials that you get for your app when you register on Facebook.




appName :: Ascii

Your application name (e.g. for OpenGraph calls).

appId :: Ascii

Your application ID.

appSecret :: Ascii

Your application secret key.

Access token

data AccessToken kind whereSource

An access token. While you can make some API calls without an access token, many require an access token and some will give you more information with an appropriate access token.

There are two kinds of access tokens:

User access token
An access token obtained after an user accepts your application. Let's you access more information about that user and act on their behalf (depending on which permissions you've asked for).
App access token
An access token that allows you to take administrative actions for your application.

These access tokens are distinguished by the phantom type on AccessToken, which can be User or App.


Typeable1 AccessToken 
Eq (AccessToken kind) 
Ord (AccessToken kind) 
Show (AccessToken kind) 
ToSimpleQuery (AccessToken kind) 

type AccessTokenData = AsciiSource

The access token data that is passed to Facebook's API calls.

hasExpired :: (Functor m, MonadIO m) => AccessToken kind -> m BoolSource

True if the access token has expired, otherwise False.

isValid :: ResourceIO m => AccessToken kind -> FacebookT anyAuth m BoolSource

True if the access token is valid. An expired access token is not valid (see hasExpired). However, a non-expired access token may not be valid as well. For example, in the case of an user access token, they may have changed their password, logged out from Facebook or blocked your app.

App access token

data App Source

Phantom type used mark an AccessToken as an app access token.


getAppAccessToken :: ResourceIO m => FacebookT Auth m (AccessToken App)Source

Get an app access token from Facebook using your credentials.

User access token

data User Source

Phantom type used mark an AccessToken as an user access token.


type RedirectUrl = TextSource

URL where the user is redirected to after Facebook authenticates the user authorizes your application. This URL should be inside the domain registered for your Facebook application.

data Permission Source

A permission that is asked for the user when he authorizes your app. Please refer to Facebook's documentation at https://developers.facebook.com/docs/reference/api/permissions/ to see which permissions are available.

This is a newtype of Text that supports only IsString. This means that to create a Permission you should use the OverloadedStrings language extension. For example,

 {-# LANGUAGE OverloadedStrings #-}

 perms :: [Permission]
 perms = ["user_about_me", "email", "offline_access"]

getUserAccessTokenStep1 :: Credentials -> RedirectUrl -> [Permission] -> TextSource

The first step to get an user access token. Returns the Facebook URL you should redirect you user to. Facebook will authenticate the user, authorize your app and then redirect the user back into the provider RedirectUrl.



:: ResourceIO m 
=> RedirectUrl

Should be exactly the same as in getUserAccessTokenStep1.

-> SimpleQuery 
-> FacebookT Auth m (AccessToken User) 

The second step to get an user access token. If the user is successfully authenticate and they authorize your application, then they'll be redirected back to the RedirectUrl you've passed to getUserAccessTokenStep1. You should take the request query parameters passed to your RedirectUrl and give to this function that will complete the user authentication flow and give you an AccessToken User.

extendUserAccessToken :: ResourceIO m => AccessToken User -> FacebookT Auth m (Either FacebookException (AccessToken User))Source

Extend the expiration time of an user access token (see https://developers.facebook.com/docs/offline-access-deprecation/). Returns Left exc if there is an error while extending, or Right token with the new user access token (which could have the same data and expiration time as before, but you can't assume this). Note that expired access tokens can't be extended, only valid tokens.

Raw access to the Graph API



:: ResourceIO m 
=> Ascii

Path (should begin with a slash /)

-> SimpleQuery

Arguments to be passed to Facebook

-> Maybe (AccessToken kind)

Optional access token

-> FacebookT anyAuth m Value 

Make a raw GET request to Facebook's Graph API. Returns a raw JSON Value.



:: ResourceIO m 
=> Ascii

Path (should begin with a slash /)

-> SimpleQuery

Arguments to be passed to Facebook

-> AccessToken kind

Access token

-> FacebookT Auth m Value 

Make a raw POST request to Facebook's Graph API. Returns a raw JSON Value.


data FacebookException Source

An exception that may be thrown by functions on this package. Includes any information provided by Facebook.



An exception coming from Facebook.


fbeType :: Text
fbeMessage :: Text

An exception coming from the fb package's code.


fbeMessage :: Text