fb: Bindings to Facebook's API.
This package exports bindings to Facebook's APIs (see
http://developers.facebook.com/). Does not have any external
dependencies and tries to use as little resources (such as
memory, sockets and CPU) as possible by using packages such as
aeson, attoparsec, bytestring, conduit, http-conduit,
text and others.
While we would like to have a complete binding to Facebook's API, this package is being developed on demand. If you need something that has not been implemented yet, please send a pull request or file an issue on GitHub (https://github.com/psibi/fb/issues).
[Skip to Readme]
Flags
Automatic Flags
| Name | Description | Default |
|---|---|---|
| debug | Print debugging info. | Disabled |
| pre-aeson-2-2-compat | Build with aeson < 2.2 where the attoparsec-aeson package didn't exist. | Disabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- fb-2.1.1.2.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Readme for fb-2.1.1.2
[back to package description]fb
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