File: README.md

package info (click to toggle)
haskell-fb 1.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 220 kB
  • sloc: haskell: 2,471; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 1,530 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
fb
--

[![Build Status](https://travis-ci.org/psibi/fb.svg?branch=master)](https://travis-ci.org/psibi/fb)

Haskell bindings to Facebook's API


## Example code to get User Access token

```haskell
{-# 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"
  }

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
```