diff options
| author | Carlos Sosa <carlos.sosa@valimail.com> | 2019-07-31 16:32:14 -0700 |
|---|---|---|
| committer | Carlos Sosa <carlos.sosa@valimail.com> | 2019-07-31 16:32:14 -0700 |
| commit | adb2efc538cc780fbc3282f6be9706191bb057d0 (patch) | |
| tree | 6c36bb7adfc979d76ec1370cf6df0cf2a3119fca /app | |
| parent | 2a104eff7548fd9ef168b312c7dfca0ea9731b6d (diff) | |
Move to specific commands per executable
Diffstat (limited to 'app')
| -rw-r--r-- | app/diff-lists-contacts/Main.hs | 44 | ||||
| -rw-r--r-- | app/timeline-delete/Main.hs | 48 |
2 files changed, 92 insertions, 0 deletions
diff --git a/app/diff-lists-contacts/Main.hs b/app/diff-lists-contacts/Main.hs new file mode 100644 index 0000000..671100c --- /dev/null +++ b/app/diff-lists-contacts/Main.hs @@ -0,0 +1,44 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE FlexibleContexts #-} + +module Main where + +import Web.Twitter.Conduit +import Web.Twitter.Types.Lens +import Control.Lens +import Conduit +import qualified Data.Conduit.List as CL + +tokens :: OAuth +tokens = twitterOAuth + { oauthConsumerKey = "" + , oauthConsumerSecret = "" + } + +credential :: Credential +credential = Credential + [ ("oauth_token", "") + , ("oauth_token_secret", "") + ] + +twInfo :: TWInfo +twInfo = def + { twToken = def { twOAuth = tokens, twCredential = credential } + , twProxy = Nothing + } + +main :: IO () +main = do + mgr <- newManager tlsManagerSettings + putStrLn $ "# your home timeline (up to 200 tweets):" + listMembers <- runConduit $ + sourceWithMaxId twInfo mgr (listMembers (ListNameParam "user/someList")) + .| (CL.isolate 200) + .| (mapC (\user -> do + user ^. userId)) + .| sinkList + + mapM_ (putStrLn . show) listMembers + + + diff --git a/app/timeline-delete/Main.hs b/app/timeline-delete/Main.hs new file mode 100644 index 0000000..c2b7765 --- /dev/null +++ b/app/timeline-delete/Main.hs @@ -0,0 +1,48 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE FlexibleContexts #-} + +module Main where + +import Web.Twitter.Conduit +import Web.Twitter.Types.Lens +import Control.Lens +import Conduit +import qualified Data.Conduit.List as CL + +tokens :: OAuth +tokens = twitterOAuth + { oauthConsumerKey = "YOUR_OAUTH_CONSUMER_KEY" + , oauthConsumerSecret = "YOUR_OAUTH_CONSUMER_SECRET" + } + +credential :: Credential +credential = Credential + [ ("oauth_token", "YOUR_OAUTH_TOKEN") + , ("oauth_token_secret", "YOUR_OAUTH_TOKEN_SECRET") + ] + +twInfo :: TWInfo +twInfo = def + { twToken = def { twOAuth = tokens, twCredential = credential } + , twProxy = Nothing + } + +main :: IO () +main = do + mgr <- newManager tlsManagerSettings + putStrLn $ "# your home timeline (up to 200 tweets):" + destroyReqs <- runConduit $ + sourceWithMaxId twInfo mgr (userTimeline (ScreenNameParam "someUser")) + .| (CL.isolate 200) + .| (mapC (\status -> do + status ^. statusId)) + .| (mapC destroyId) + .| (mapC (\req -> do + callWithResponse twInfo mgr req)) + .| sinkList + + resp <- sequence destroyReqs + mapM_ (putStrLn . show) resp + + + |
