我坚持使用haskell类型。
{-# LANGUAGE OverloadedStrings #-}
module Main (
main
) where
import qualified Facebook as FB
import Network.HTTP.Conduit (withManager)
import Control.Monad.IO.Class (liftIO)
import System.IO
app :: FB.Credentials
app = FB.Credentials "localhost" "249348058430770" "..."
url :: FB.RedirectUrl
url = "http://localhost/fb"
perms :: [FB.Permission]
perms = ["user_about_me", "email"]
main :: IO ()
main = do
fbAuthUrl <- FB.getUserAccessTokenStep1 url perms
liftIO $ print fbAuthUrl
argument <- readLn
token <- FB.getUserAccessTokenStep2 url [argument]
withManager $ \manager -> do
FB.runFacebookT app manager $ do
u <- FB.getUser "me" [] token
liftIO $ print (FB.userEmail u)
错误
src/Main.hs:23:18:
Couldn't match expected type `IO t0'
with actual type `FB.FacebookT
FB.Auth m0 text-0.11.2.0:Data.Text.Internal.Text'
In the return type of a call of `FB.getUserAccessTokenStep1'
In a stmt of a 'do' block:
fbAuthUrl <- FB.getUserAccessTokenStep1 url perms
In the expression:
do { fbAuthUrl <- FB.getUserAccessTokenStep1 url perms;
liftIO $ print fbAuthUrl;
argument <- readLn;
token <- FB.getUserAccessTokenStep2 url [argument];
.... }