-import qualified Data.ByteString.Lazy as B
-import qualified Data.ByteString.Char8 as BC
-import qualified Data.Conduit as C
-import Data.Conduit.Binary (sinkLbs)
-import Network.HTTP.Conduit
+import qualified Data.ByteString.Lazy as B ( ByteString )
+import qualified Data.ByteString.Char8 as BC ( pack )
+import Network.HTTP.Client (
+ httpLbs,
+ newManager,
+ parseUrl,
+ responseBody )
+import Network.HTTP.Client.TLS ( tlsManagerSettings )
-- | Given username's last status id, constructs the API URL for
-- username's new statuses. Essentially, 'user_timeline_url' with a
-- "since_id" parameter tacked on.
user_new_statuses_url :: String -> Integer -> String
user_new_statuses_url username last_status_id =
-- | Given username's last status id, constructs the API URL for
-- username's new statuses. Essentially, 'user_timeline_url' with a
-- "since_id" parameter tacked on.
user_new_statuses_url :: String -> Integer -> String
user_new_statuses_url username last_status_id =
- concat [ user_timeline_url username,
- "&since_id=" ++ (show last_status_id) ]
-
-
-get_status :: Cfg -> Integer -> IO B.ByteString
-get_status cfg status_id = do
- let uri = status_url status_id
- http_get cfg uri
+ url ++ "&since_id=" ++ since_id
+ where
+ url = user_timeline_url username
+ since_id = show last_status_id
-- | Retrieve a URL, or crash.
http_get :: Cfg -> String -> IO B.ByteString
http_get cfg url = do
-- | Retrieve a URL, or crash.
http_get :: Cfg -> String -> IO B.ByteString
http_get cfg url = do
-
- C.runResourceT $ do
- signed_request <- signOAuth oauth credential request
- response <- http signed_request manager
- responseBody response C.$$+- sinkLbs
+ signed_request <- signOAuth oauth credential request
+ response <- httpLbs signed_request manager
+ return $ responseBody response