fb 0.9 → 0.9.1
raw patch · 4 files changed
+29/−7 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Facebook: createCheckin :: (MonadResource m, MonadBaseControl IO m) => Id -> (Double, Double) -> [Argument] -> UserAccessToken -> FacebookT Auth m Id
Files
- fb.cabal +1/−1
- src/Facebook.hs +1/−0
- src/Facebook/Auth.hs +9/−5
- src/Facebook/OpenGraph.hs +18/−1
fb.cabal view
@@ -1,5 +1,5 @@ name: fb-version: 0.9+version: 0.9.1 license: BSD3 license-file: LICENSE author: Felipe Lessa
src/Facebook.hs view
@@ -41,6 +41,7 @@ -- * Facebook's Open Graph API , createAction , Action+ , createCheckin , (#=) , SimpleType(..)
src/Facebook/Auth.hs view
@@ -237,11 +237,15 @@ -- | Extend the expiration time of an user access token (see--- <https://developers.facebook.com/docs/offline-access-deprecation/>).--- 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+-- <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, C.MonadResource m) => UserAccessToken
src/Facebook/OpenGraph.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE FlexibleContexts, OverloadedStrings #-} module Facebook.OpenGraph ( createAction+ , createCheckin , Action(..) , (#=) , SimpleType(..)@@ -14,6 +15,8 @@ import Data.Function (on) import Data.List (intersperse) import Data.Text (Text)+import qualified Data.Text.Lazy as TL (toStrict)+import Data.Text.Lazy.Builder (toLazyText) -- import Data.Typeable (Typeable, Typeable1) import Data.Int (Int8, Int16, Int32) import Data.Word (Word8, Word16, Word32, Word)@@ -22,7 +25,8 @@ import System.Locale (defaultTimeLocale) -- import qualified Control.Exception.Lifted as E--- import qualified Data.Aeson as A+import qualified Data.Aeson as A+import qualified Data.Aeson.Encode as AE (fromValue) import qualified Data.ByteString.Char8 as B import qualified Data.Conduit as C -- import qualified Data.Text as T@@ -63,6 +67,19 @@ Nothing -> post "/me/" usertoken Just apptoken -> post ("/" <> accessTokenUserId usertoken <> "/") apptoken +-- | Creates a 'check-in' and returns its id. Place and+-- coordinates are both required by Facebook.+createCheckin :: (C.MonadResource m, MonadBaseControl IO m) =>+ Id -- ^ Place Id+ -> (Double, Double) -- ^ (Latitude, Longitude)+ -> [Argument] -- ^ Other arguments of the action.+ -> UserAccessToken -- ^ Required user access token.+ -> FacebookT Auth m Id+createCheckin pid (lat,lon) args usertoken = do+ let coords = ("coordinates", toBS $ A.object ["latitude" A..= lat, "longitude" A..= lon])+ body = ("place" #= pid) : coords : args+ toBS = TE.encodeUtf8 . TL.toStrict . toLazyText . AE.fromValue+ postObject "me/checkins" body usertoken -- | An action of your app. Please refer to Facebook's