-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | 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/meteficha/fb/issues). @package fb @version 0.11 module Facebook -- | 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). data FacebookT auth m a -- | Run a computation in the FacebookT monad transformer with your -- credentials. runFacebookT :: Credentials -> Manager -> FacebookT Auth m a -> m a -- | Run a computation in the FacebookT monad without credentials. runNoAuthFacebookT :: Manager -> FacebookT NoAuth m a -> m a -- | Same as runFacebookT, but uses Facebook's beta tier (see -- https://developers.facebook.com/support/beta-tier/). beta_runFacebookT :: Credentials -> Manager -> FacebookT Auth m a -> m a -- | Same as runNoAuthFacebookT, but uses Facebook's beta tier (see -- https://developers.facebook.com/support/beta-tier/). beta_runNoAuthFacebookT :: Manager -> FacebookT NoAuth m a -> m a -- | Phantom type stating that you have provided your Credentials -- and thus have access to the whole API. data Auth -- | 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. data NoAuth -- | Credentials that you get for your app when you register on Facebook. data Credentials Credentials :: ByteString -> ByteString -> ByteString -> Credentials -- | Your application name (e.g. for OpenGraph calls). appName :: Credentials -> ByteString -- | Your application ID. appId :: Credentials -> ByteString -- | Your application secret key. appSecret :: Credentials -> ByteString -- | 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: -- -- -- -- These two kinds of access tokens are distinguished by the phantom type -- on AccessToken, which can be UserKind or AppKind. data AccessToken kind UserAccessToken :: UserId -> AccessTokenData -> UTCTime -> AccessToken UserKind AppAccessToken :: AccessTokenData -> AccessToken AppKind -- | Type synonym for AccessToken UserKind. type UserAccessToken = AccessToken UserKind -- | Type synonym for AccessToken AppKind. type AppAccessToken = AccessToken AppKind -- | The access token data that is passed to Facebook's API calls. type AccessTokenData = ByteString -- | True if the access token has expired, otherwise -- False. hasExpired :: (Functor m, MonadIO m) => AccessToken anyKind -> m Bool -- | 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. isValid :: (MonadBaseControl IO m, MonadResource m) => AccessToken anyKind -> FacebookT anyAuth m Bool -- | Phantom type used mark an AccessToken as an app access token. data AppKind -- | Get an app access token from Facebook using your credentials. getAppAccessToken :: (MonadResource m, MonadBaseControl IO m) => FacebookT Auth m AppAccessToken -- | Phantom type used mark an AccessToken as an user access token. data UserKind -- | 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. type RedirectUrl = Text -- | 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"]
--   
data Permission -- | 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. getUserAccessTokenStep1 :: Monad m => RedirectUrl -> [Permission] -> FacebookT Auth m Text -- | 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 -- UserAccessToken. getUserAccessTokenStep2 :: (MonadBaseControl IO m, MonadResource m) => RedirectUrl -> [Argument] -> FacebookT Auth m UserAccessToken -- | The URL an user should be redirected to in order to log them out of -- their Facebook session. Facebook will then redirect the user to the -- provided URL after logging them out. Note that, at the time of this -- writing, Facebook's policies require you to log the user out of -- Facebook when they ask to log out of your site. -- -- Note also that Facebook may refuse to redirect the user to the -- provided URL if their user access token is invalid. In order to -- prevent this bug, we suggest that you use isValid before -- redirecting the user to the URL provided by getUserLogoutUrl -- since this function doesn't do any validity checks. getUserLogoutUrl :: Monad m => UserAccessToken -> RedirectUrl -> FacebookT Auth m Text -- | Extend the expiration time of an user access token (see -- https://developers.facebook.com/docs/offline-access-deprecation/, -- https://developers.facebook.com/roadmap/offline-access-removal/). -- Only short-lived user access tokens may extended into long-lived user -- access tokens, you must get a new short-lived user access token if you -- need to extend a long-lived one. 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. extendUserAccessToken :: (MonadBaseControl IO m, MonadResource m) => UserAccessToken -> FacebookT Auth m (Either FacebookException UserAccessToken) -- | Parses a Facebook signed request -- (https://developers.facebook.com/docs/authentication/signed_request/), -- verifies its authencity and integrity using the HMAC and decodes its -- JSON object. parseSignedRequest :: (FromJSON a, Monad m) => ByteString -> FacebookT Auth m (Maybe a) -- | A Facebook user profile (see -- https://developers.facebook.com/docs/reference/api/user/). -- -- NOTE: We still don't support all fields supported by Facebook. -- Please fill an issue if you need access to any other fields. data User User :: UserId -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Gender -> Maybe Text -> Maybe Text -> Maybe Bool -> Maybe Text -> Maybe UserLocation -> User userId :: User -> UserId userName :: User -> Maybe Text userFirstName :: User -> Maybe Text userMiddleName :: User -> Maybe Text userLastName :: User -> Maybe Text userGender :: User -> Maybe Gender userLocale :: User -> Maybe Text userUsername :: User -> Maybe Text userVerified :: User -> Maybe Bool userEmail :: User -> Maybe Text userLocation :: User -> Maybe UserLocation -- | A Facebook user id such as 1008905713901. type UserId = ByteString -- | An user's gender. data Gender Male :: Gender Female :: Gender -- | An user's location. data UserLocation UserLocation :: Id -> Text -> UserLocation userLocationId :: UserLocation -> Id userLocationName :: UserLocation -> Text -- | Get an user using his user ID. The user access token is optional, but -- when provided more information can be returned back by Facebook. The -- user ID may be "me", in which case you must provide an user -- access token and information about the token's owner is given. getUser :: (MonadResource m, MonadBaseControl IO m) => UserId -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m User -- | Search users by keyword. searchUsers :: (MonadResource m, MonadBaseControl IO m) => ByteString -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m (SearchResultPage User) -- | A Facebook page (see -- https://developers.facebook.com/docs/reference/api/page/). -- -- NOTE: Does not yet support all fields. Please file an issue if -- you need any other fields. data Page Page :: ByteString -> Maybe Text -> Maybe ByteString -> Maybe Text -> Maybe Bool -> Maybe Bool -> Maybe Integer -> Maybe UserLocation -> Maybe Text -> Maybe Integer -> Maybe ByteString -> Maybe ByteString -> Maybe Integer -> Page pageId :: Page -> ByteString pageName :: Page -> Maybe Text pageLink :: Page -> Maybe ByteString pageCategory :: Page -> Maybe Text pageIsPublished :: Page -> Maybe Bool pageCanPost :: Page -> Maybe Bool pageLikes :: Page -> Maybe Integer pageLocation :: Page -> Maybe UserLocation pagePhone :: Page -> Maybe Text pageCheckins :: Page -> Maybe Integer pagePicture :: Page -> Maybe ByteString pageWebsite :: Page -> Maybe ByteString pageTalkingAboutCount :: Page -> Maybe Integer -- | Get a page using its ID. The user access token is optional. getPage :: (MonadResource m, MonadBaseControl IO m) => ByteString -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m Page -- | Search pages by keyword. The user access token is optional. searchPages :: (MonadResource m, MonadBaseControl IO m) => ByteString -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m (SearchResultPage Page) -- | Creates an Open Graph action on the user's timeline. Returns the -- Id of the newly created action. For example: -- --
--   now <- liftIO getCurrentTime
--   createAction "cook"
--                [ "recipe" #= "http://example.com/cookie.html"
--                , "when"   #= now ]
--                token
--   
createAction :: (MonadResource m, MonadBaseControl IO m) => Action -> [Argument] -> Maybe AppAccessToken -> UserAccessToken -> FacebookT Auth m Id -- | An action of your app. Please refer to Facebook's documentation at -- https://developers.facebook.com/docs/opengraph/keyconcepts/#actions-objects -- to see how you can create actions. -- -- This is a newtype of ByteString that supports only -- IsString. This means that to create an Action you should -- use the OverloadedStrings language extension. For example, -- --
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   foo token = do
--     ...
--     createAction "cook" [...] token
--   
data Action -- | Creates a 'check-in' and returns its id. Place and coordinates are -- both required by Facebook. createCheckin :: (MonadResource m, MonadBaseControl IO m) => Id -> (Double, Double) -> [Argument] -> UserAccessToken -> FacebookT Auth m Id -- | Query the Facebook Graph using FQL. You may want to use -- FQLResult when parsing the returned JSON. fqlQuery :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => Text -> Maybe (AccessToken anyKind) -> FacebookT anyAuth m a -- | Parses an FQL query result. FQL query results are always of the form -- --
--   { data: [ret1, ret2, ...] }
--   
-- -- This newtype unwraps the array from the data -- field automatically for you, so you may write something like: -- --
--   FQLResult [...] <- fqlQuery ...
--   
newtype FQLResult a FQLResult :: [a] -> FQLResult a -- | Create an Argument with a SimpleType. See the docs on -- createAction for an example. (#=) :: SimpleType a => ByteString -> a -> Argument -- | Class for data types that may be represented as a Facebook simple -- type. (see -- https://developers.facebook.com/docs/opengraph/simpletypes/). class SimpleType a encodeFbParam :: SimpleType a => a -> ByteString -- | Make a raw GET request to Facebook's Graph API. Returns a raw -- JSON Value. getObject :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => ByteString -> [Argument] -> Maybe (AccessToken anyKind) -> FacebookT anyAuth m a -- | Make a raw POST request to Facebook's Graph API. Returns a -- raw JSON Value. postObject :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => ByteString -> [Argument] -> AccessToken anyKind -> FacebookT Auth m a -- | The identification code of an object. newtype Id Id :: ByteString -> Id idCode :: Id -> ByteString -- | An argument given to an API call. type Argument = (ByteString, ByteString) -- | Make a raw GET request to the /search endpoint of Facebook’s -- Graph API. Returns a raw JSON Value. searchObjects :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => ByteString -> ByteString -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m (SearchResultPage a) -- | The result object for searchObjects. The type parameter is expected to -- be an instance of A.FromJSON, but nothing has been done to assure that -- Facebook will return the type expected. data SearchResultPage a SearchResultPage :: [a] -> Maybe Pager -> SearchResultPage a searchResults :: SearchResultPage a -> [a] searchPage :: SearchResultPage a -> Maybe Pager -- | An exception that may be thrown by functions on this package. Includes -- any information provided by Facebook. data FacebookException -- | An exception coming from Facebook. FacebookException :: Text -> Text -> FacebookException fbeType :: FacebookException -> Text fbeMessage :: FacebookException -> Text -- | An exception coming from the fb package's code. FbLibraryException :: Text -> FacebookException fbeMessage :: FacebookException -> Text -- | Retrieves the Text back from a Permission. Most of the -- time you won't need to use this function, but you may need it if -- you're a library author. unPermission :: Permission -> Text