BSD-3-Clause licensed by Felipe Lessa, Sibi Prabakaran
Maintained by Sibi
This version can be pinned in stack with:fb-2.1.1.1@sha256:053ea2395d89c2c87e4fc85d2bc2937510fd28b5e0c43620db3203ca7807842a,3075

Module documentation for 2.1.1.1

fb

Build Status

Haskell bindings to Facebook’s API

Example code to get User Access token

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

import Facebook
import Network.HTTP.Client
import Network.HTTP.Client.TLS
import Control.Monad.Trans.Control
import Control.Monad.Trans.Resource
import Control.Monad.IO.Class
import Data.Monoid ((<>))
import Data.ByteString.Char8 (pack)
import Data.Text hiding (pack)
import Data.Aeson
import qualified Data.Text.Encoding as TE

myCreds :: Credentials
myCreds =
  Credentials
  { appName = "Your_APP_Name"
  , appId = "your_app_id"
  , appSecret = "xxxxxxxxxxxxxxxxx"
  , appSecretProof = False
  }

main :: IO ()
main = do
  mgr <- newManager tlsManagerSettings
  let redirectUrl = "https://www.yourdomain.com/"
  runResourceT $
    runFacebookT myCreds mgr $
    do url1 <- getUserAccessTokenStep1 redirectUrl ["public_profile", "email"]
       liftIO $ print ("Paste the url in browser and get code: " <> url1)
       code <- liftIO $ getLine
       token <- getUserAccessTokenStep2 redirectUrl [("code", pack code)]
       liftIO $ print token

Snippet to get your Profile Picture:

       (picture :: Value) <-
         getObject "/me/picture" [("redirect", "0")] (Just token)
       liftIO $ print picture

Snippet to get your firstname, lastname:

       user <- getUser "me" [("fields", "first_name,last_name")] (Just token)
       liftIO $ print user

Changes

Version 2.1.1.1

  • Add support for Aeson v2+.

Version 2.1.0

  • Same release as 2.0.1 bound follows PVP properly

Version 2.0.1

  • Fix MonadUnliftIO instance for FacebookT
  • Have upper bound on unliftio and related packages

Version 2.0.0

  • Remove following dependency:
    • base16-bytestring
    • base64-bytestring
    • cereal
    • crypto-api
    • cryptohash
    • cryptohash-cryptoapi
    • old-locale
  • Introduce new dependency:
    • cryptonite
    • memory
  • Add new function setApiVersion
  • Add Graph API version parameter. Avoid hardcoded v2.8.
  • Expose setApiVersion and getApiVersion function
  • Default API endpoint updated to v3.2
  • Add appsecret_proof verification.
  • Fix appsecret_proof verification encoding.

Version 1.2.1

  • Make it work for ghc-8.4. See #3

Version 1.2.0

  • Rewrote fb for conduit-1.3.0
  • Fixed various warnings and did general cleanup
  • Fixed fetchNextPage/fetchPreviousPage test by adding (“filter”, “stream”) for comments api.
  • Made lower bound of http-conduit to 2.3.0

Version 1.1.1

  • Make versioned call. By default now it uses `v2.8.
  • disassociateTestuser function added.
  • getPage_ function added which accepts AppAccessToken as opposed to getPage function.
  • Fixed a bug in getObjectBool
  • Travis CI added