-- 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.14 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 -- | Transform the computation inside a FacebookT. mapFacebookT :: (m a -> n b) -> FacebookT anyAuth m a -> FacebookT anyAuth n b -- | 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 :: Text -> Text -> Text -> Credentials -- | Your application name (e.g. for Open Graph calls). appName :: Credentials -> Text -- | Your application ID. appId :: Credentials -> Text -- | Your application secret key. appSecret :: Credentials -> Text -- | 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: -- --
-- {-# 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 Place -> 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 Place
-- | A Facebook user ID such as 1008905713901.
type UserId = Id
-- | An user's gender.
data Gender
Male :: Gender
Female :: Gender
-- | 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) => Text -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m (Pager User)
-- | Get a list of check-ins made by a given user.
getUserCheckins :: (MonadResource m, MonadBaseControl IO m) => UserId -> [Argument] -> UserAccessToken -> FacebookT anyAuth m (Pager Checkin)
-- | A friend connection of a User.
data Friend
Friend :: UserId -> Text -> Friend
friendId :: Friend -> UserId
friendName :: Friend -> Text
-- | Get the list of friends of the given user.
getUserFriends :: (MonadResource m, MonadBaseControl IO m) => UserId -> [Argument] -> UserAccessToken -> FacebookT anyAuth m (Pager Friend)
-- | 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 :: Id -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Bool -> Maybe Bool -> Maybe Integer -> Maybe Location -> Maybe Text -> Maybe Integer -> Maybe Text -> Maybe Text -> Maybe Integer -> Page
pageId :: Page -> Id
pageName :: Page -> Maybe Text
pageLink :: Page -> Maybe Text
pageCategory :: Page -> Maybe Text
pageIsPublished :: Page -> Maybe Bool
pageCanPost :: Page -> Maybe Bool
pageLikes :: Page -> Maybe Integer
pageLocation :: Page -> Maybe Location
pagePhone :: Page -> Maybe Text
pageCheckins :: Page -> Maybe Integer
pagePicture :: Page -> Maybe Text
pageWebsite :: Page -> Maybe Text
pageTalkingAboutCount :: Page -> Maybe Integer
-- | Get a page using its ID. The user access token is optional.
getPage :: (MonadResource m, MonadBaseControl IO m) => Id -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m Page
-- | Search pages by keyword. The user access token is optional.
searchPages :: (MonadResource m, MonadBaseControl IO m) => Text -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m (Pager Page)
-- | 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 Text 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 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 -- | A Facebook check-in (see -- https://developers.facebook.com/docs/reference/api/checkin/). -- -- NOTE: We still don't support all fields supported by Facebook. -- Please fill an issue if you need access to any other fields. data Checkin Checkin :: Id -> Maybe CheckinFrom -> Maybe Place -> Maybe UTCTime -> Maybe (Pager Tag) -> Maybe Text -> Checkin checkinId :: Checkin -> Id checkinFrom :: Checkin -> Maybe CheckinFrom checkinPlace :: Checkin -> Maybe Place checkinCreatedTime :: Checkin -> Maybe UTCTime checkinTags :: Checkin -> Maybe (Pager Tag) checkinMessage :: Checkin -> Maybe Text -- | Information about the user who made the check-in. data CheckinFrom CheckinFrom :: UserId -> Text -> CheckinFrom checkinFromId :: CheckinFrom -> UserId checkinFromName :: CheckinFrom -> Text -- | Get a checkin from its ID. The user access token is optional, but when -- provided more information can be returned back by Facebook. getCheckin :: (MonadResource m, MonadBaseControl IO m) => Id -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m Checkin -- | Creates a 'check-in' and returns its ID. Place and coordinates are -- both required by Facebook. createCheckin :: (MonadResource m, MonadBaseControl IO m) => Id -> GeoCoordinates -> [Argument] -> UserAccessToken -> FacebookT Auth m Id -- | 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 -- | Information about a place. This is not a Graph Object, instead it's -- just a field of a Object. (Not to be confused with the Page -- object.) data Place Place :: Id -> Maybe Text -> Maybe Location -> Place -- | Page ID. placeId :: Place -> Id -- | Page name. placeName :: Place -> Maybe Text placeLocation :: Place -> Maybe Location -- | A geographical location. data Location Location :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe GeoCoordinates -> Location locationStreet :: Location -> Maybe Text locationCity :: Location -> Maybe Text locationState :: Location -> Maybe Text locationCountry :: Location -> Maybe Text locationZip :: Location -> Maybe Text locationCoords :: Location -> Maybe GeoCoordinates -- | Geographical coordinates. data GeoCoordinates GeoCoordinates :: !Double -> !Double -> GeoCoordinates latitude :: GeoCoordinates -> !Double longitude :: GeoCoordinates -> !Double -- | A tag (i.e. "I'll tag you on my post"). data Tag Tag :: Id -> Text -> Tag -- | Who is tagged. tagId :: Tag -> Id -- | Name of the tagged person. tagName :: Tag -> Text -- | Many Graph API results are returned as a JSON object with the -- following structure: -- --
-- {
-- "data": [
-- ...item 1...,
-- :
-- ...item n...
-- ],
-- "paging": {
-- "previous": "http:...link to previous page...",
-- "next": "http:...link to next page..."
-- }
-- }
--
--
-- Only the "data" field is required, the others may or may not
-- appear.
--
-- A Pager a datatype encodes such result where each item has
-- type a. You may use functions fetchNextPage and
-- fetchPreviousPage to navigate through the results.
data Pager a
Pager :: [a] -> Maybe String -> Maybe String -> Pager a
pagerData :: Pager a -> [a]
pagerPrevious :: Pager a -> Maybe String
pagerNext :: Pager a -> Maybe String
-- | Tries to fetch the next page of a Pager. Returns Nothing
-- whenever the current Pager does not have a pagerNext.
fetchNextPage :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => Pager a -> FacebookT anyAuth m (Maybe (Pager a))
-- | Tries to fetch the previous page of a Pager. Returns
-- Nothing whenever the current Pager does not have a
-- pagerPrevious.
fetchPreviousPage :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => Pager a -> FacebookT anyAuth m (Maybe (Pager a))
-- | Tries to fetch all next pages and returns a Source with all
-- results. The Source will include the results from this page as
-- well. Previous pages will not be considered. Next pages will be
-- fetched on-demand.
fetchAllNextPages :: (Monad m, MonadResourceBase n, FromJSON a) => Pager a -> FacebookT anyAuth m (Source n a)
-- | Tries to fetch all previous pages and returns a Source with all
-- results. The Source will include the results from this page as
-- well. Next pages will not be considered. Previous pages will be
-- fetched on-demand.
fetchAllPreviousPages :: (Monad m, MonadResourceBase n, FromJSON a) => Pager a -> FacebookT anyAuth m (Source n a)
-- | Add or modify a subscription for real-time updates. If there were no
-- previous subscriptions for the given RealTimeUpdateObject, then
-- a new subscription is created. If there was any previous subscription
-- for the given RealTimeUpdateObject, it's overriden by this one
-- (even if the other subscription had a different callback URL).
modifySubscription :: (MonadResource m, MonadBaseControl IO m) => RealTimeUpdateObject -> [RealTimeUpdateField] -> RealTimeUpdateUrl -> RealTimeUpdateToken -> AppAccessToken -> FacebookT Auth m ()
-- | List current real-time update subscriptions.
listSubscriptions :: (MonadResource m, MonadBaseControl IO m) => AppAccessToken -> FacebookT Auth m [RealTimeUpdateSubscription]
-- | The type of objects that a real-time update refers to.
data RealTimeUpdateObject
UserRTUO :: RealTimeUpdateObject
PermissionsRTUO :: RealTimeUpdateObject
PageRTUO :: RealTimeUpdateObject
ErrorsRTUO :: RealTimeUpdateObject
OtherRTUO :: Text -> RealTimeUpdateObject
-- | A field of a RealTimeUpdateObject that you would like to
-- receive notifications when changed.
type RealTimeUpdateField = ByteString
-- | The URL on your server that will receive the real-time updates. Please
-- refer to Facebook's documentation in order to see what this URL needs
-- to implement.
type RealTimeUpdateUrl = Text
-- | A token that is sent back by Facebook's servers to your server in
-- order to verify that you really were trying to modify your
-- subscription.
type RealTimeUpdateToken = ByteString
-- | Information returned by Facebook about a real-time update notification
-- subscription.
data RealTimeUpdateSubscription
RealTimeUpdateSubscription :: RealTimeUpdateObject -> RealTimeUpdateUrl -> [RealTimeUpdateField] -> Bool -> RealTimeUpdateSubscription
rtusObject :: RealTimeUpdateSubscription -> RealTimeUpdateObject
rtusCallbackUrl :: RealTimeUpdateSubscription -> RealTimeUpdateUrl
rtusFields :: RealTimeUpdateSubscription -> [RealTimeUpdateField]
rtusActive :: RealTimeUpdateSubscription -> Bool
-- | Verifies the input's authenticity (i.e. it comes from Facebook) and
-- integrity by calculating its HMAC-SHA1 (using your application secret
-- as the key) and verifying that it matches the value from the HTTP
-- request's X-Hub-Signature header's value. If it's not valid,
-- Nothing is returned, otherwise Just data is returned
-- where data is the original data.
verifyRealTimeUpdateNotifications :: Monad m => ByteString -> ByteString -> FacebookT Auth m (Maybe ByteString)
-- | Same as verifyRealTimeUpdateNotifications but also parses the
-- response as JSON. Returns Nothing if either the signature is
-- invalid or the data can't be parsed (use
-- verifyRealTimeUpdateNotifications if you need to distinguish
-- between these two error conditions).
getRealTimeUpdateNotifications :: (Monad m, FromJSON a) => ByteString -> ByteString -> FacebookT Auth m (Maybe (RealTimeUpdateNotification a))
-- | When data changes and there's a valid subscription, Facebook will
-- POST to your RealTimeUpdateUrl with a JSON-encoded
-- object containing the notifications. A 'RealTimeUpdateNotification a'
-- represents such object where a is type of the entries (e.g.,
-- RealTimeUpdateNotificationUserEntry).
--
-- If you have a single RealTimeUpdateUrl for different kinds of
-- notifications, you may parse a RealTimeUpdateNotification
-- Value and then manually parse the Value depending
-- on the value of rtunObject.
--
-- We recommend using getRealTimeUpdateNotifications.
data RealTimeUpdateNotification a
RealTimeUpdateNotification :: RealTimeUpdateObject -> [a] -> RealTimeUpdateNotification a
rtunObject :: RealTimeUpdateNotification a -> RealTimeUpdateObject
rtunEntries :: RealTimeUpdateNotification a -> [a]
-- | A notification for the UserRTUO object.
data RealTimeUpdateNotificationUserEntry
RealTimeUpdateNotificationUserEntry :: Id -> [RealTimeUpdateField] -> Integer -> RealTimeUpdateNotificationUserEntry
rtuneUserId :: RealTimeUpdateNotificationUserEntry -> Id
rtuneChangedFields :: RealTimeUpdateNotificationUserEntry -> [RealTimeUpdateField]
rtuneTime :: RealTimeUpdateNotificationUserEntry -> Integer
-- | Query the Facebook Graph using FQL.
fqlQuery :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => Text -> Maybe (AccessToken anyKind) -> FacebookT anyAuth m (Pager a)
-- | newtype wrapper around UTCTime that is able to parse
-- FQL's time representation as seconds since the Unix epoch.
newtype FQLTime
FQLTime :: UTCTime -> FQLTime
unFQLTime :: FQLTime -> UTCTime
-- | newtype wrapper around lists that works around FQL's strange
-- lists.
--
-- For example, if you fetch the tagged_uids field from
-- location_post, you'll find that Facebook's FQL represents an
-- empty list of tagged UIDs as plain JSON array ([]). However,
-- it represents a singleton list as an object {"1234": 1234}
-- instead of the much more correct [1234].
--
-- On the other hand, not all FQL arrays are represented in this bogus
-- manner. Also, some so-called arrays by FQL's documentation are
-- actually objects, see FQLObject.
newtype FQLList a
FQLList :: [a] -> FQLList a
unFQLList :: FQLList a -> [a]
-- | newtype wrapper around any object that works around FQL's
-- strange objects.
--
-- For example, if you fetch the app_data field from
-- stream, you'll find that empty objects are actually
-- represented as empty lists [] instead of a proper empty
-- object {}. Also note that FQL's documentation says that
-- app_data is an array, which it clear is not. See also
-- FQLList.
newtype FQLObject a
FQLObject :: a -> FQLObject a
unFQLObject :: FQLObject a -> a
-- | Get a list of test users.
getTestUsers :: (MonadResource m, MonadBaseControl IO m) => AppAccessToken -> FacebookT Auth m (Pager TestUser)
-- | Remove an existing test user.
removeTestUser :: (MonadResource m, MonadBaseControl IO m) => TestUser -> AppAccessToken -> FacebookT Auth m Bool
-- | Create a new test user.
createTestUser :: (MonadResource m, MonadBaseControl IO m) => CreateTestUser -> AppAccessToken -> FacebookT Auth m TestUser
-- | Make a friend connection between two test users.
--
-- This is how Facebook's API work: two calls must be made. The first
-- call has the format: "/userA_id/friends/userB_id" with the access
-- token of user A as query parameter. The second call has the format:
-- "/userB_id/friends/userA_id" with the access token of user B as query
-- parameter. The first call creates a friend request and the second call
-- accepts the friend request.
makeFriendConn :: (MonadResource m, MonadBaseControl IO m) => TestUser -> TestUser -> FacebookT Auth m ()
-- | Create an UserAccessToken from a TestUser. It's
-- incomplete because it will not have the right expiration time.
incompleteTestUserAccessToken :: TestUser -> Maybe UserAccessToken
-- | A Facebook test user.
data TestUser
TestUser :: UserId -> Maybe AccessTokenData -> Maybe Text -> Maybe Text -> Maybe Text -> TestUser
tuId :: TestUser -> UserId
tuAccessToken :: TestUser -> Maybe AccessTokenData
tuLoginUrl :: TestUser -> Maybe Text
tuEmail :: TestUser -> Maybe Text
tuPassword :: TestUser -> Maybe Text
-- | Data type used to hold information of a new test user. This type also
-- accepts a Data.Default value.
data CreateTestUser
CreateTestUser :: CreateTestUserInstalled -> Maybe Text -> Maybe Text -> CreateTestUser
ctuInstalled :: CreateTestUser -> CreateTestUserInstalled
ctuName :: CreateTestUser -> Maybe Text
ctuLocale :: CreateTestUser -> Maybe Text
-- | Specify if the app is to be installed on the new test user. If it is,
-- then you must tell what permissions should be given.
data CreateTestUserInstalled
CreateTestUserNotInstalled :: CreateTestUserInstalled
CreateTestUserInstalled :: [Permission] -> CreateTestUserInstalled
ctuiPermissions :: CreateTestUserInstalled -> [Permission]
-- | Uses Facebook's default. It seems that this is equivalent to
-- CreateTestUserInstalled [], but Facebook's documentation is
-- not clear about it.
CreateTestUserFbDefault :: CreateTestUserInstalled
-- | Make a raw GET request to Facebook's Graph API.
getObject :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => Text -> [Argument] -> Maybe (AccessToken anyKind) -> FacebookT anyAuth m a
-- | Make a raw POST request to Facebook's Graph API.
postObject :: (MonadResource m, MonadBaseControl IO m, FromJSON a) => Text -> [Argument] -> AccessToken anyKind -> FacebookT Auth m a
-- | 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) => Text -> Text -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m (Pager a)
-- | The identification code of an object.
newtype Id
Id :: Text -> Id
idCode :: Id -> Text
-- | An argument given to an API call.
type Argument = (ByteString, ByteString)
-- | 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