Safe Haskell | None |
---|---|
Language | Haskell2010 |
Various utilities to tweet using the twitter api
Make sure you have a file credentials file (default the executable looks for is `.cred`) with the following info:
api-key: API_KEY api-sec: API_SECRE tok: OAUTH_TOKEN tok-sec: TOKEN_SECRET
- basicTweet :: String -> FilePath -> IO Int
- tweetData :: Tweet -> FilePath -> IO Int
- thread :: String -> [String] -> Maybe Int -> Int -> FilePath -> IO ()
- data Tweet = Tweet {}
- data TweetEntity = TweetEntity {
- _text :: String
- _name :: String
- _screenName :: String
- _tweetId :: Int
- _quoted :: Maybe TweetEntity
- _retweets :: Int
- _favorites :: Int
- type Timeline = [TweetEntity]
- trimUser :: Lens' Tweet Bool
- status :: Lens' Tweet String
- replyID :: Lens' Tweet (Maybe Int)
- handles :: Lens' Tweet [String]
- tweetId :: Lens' TweetEntity Int
- text :: Lens' TweetEntity String
- screenName :: Lens' TweetEntity String
- retweets :: Lens' TweetEntity Int
- quoted :: Lens' TweetEntity (Maybe TweetEntity)
- name :: Lens' TweetEntity String
- favorites :: Lens' TweetEntity Int
- signRequest :: FilePath -> Request -> IO Request
- urlString :: Tweet -> String
- getTimeline :: Int -> FilePath -> IO (Either (ParseError Char Dec) Timeline)
- showTimeline :: Int -> Bool -> FilePath -> IO String
- getProfile :: String -> Int -> FilePath -> IO (Either (ParseError Char Dec) Timeline)
- showProfile :: String -> Int -> Bool -> FilePath -> IO String
- showBest :: String -> Bool -> FilePath -> IO String
- getDMs :: Show t => t -> FilePath -> IO (Either (ParseError Char Dec) Timeline)
- showDMs :: Show t => t -> Bool -> FilePath -> IO String
- getRaw :: String -> Maybe Int -> FilePath -> IO [String]
Functions to tweet
basicTweet :: String -> FilePath -> IO Int Source #
Tweet a string given a path to credentials; return the id of the status.
basicTweet "On the airplane." ".cred"
tweetData :: Tweet -> FilePath -> IO Int Source #
tweet, given a Tweet
and path to credentials. Return id of posted tweet.
thread :: String -> [String] -> Maybe Int -> Int -> FilePath -> IO () Source #
thread tweets together nicely. Takes a string, a list of handles to reply to, plus the ID of the status you're replying to.
If you need to thread tweets without replying, pass a Nothing
as the third argument.
thread "Hi I'm back in New York!" ["friend1","friend2"] Nothing 1 ".cred"
Data type for a tweet
Data type for our request: consists of the status text, whether to trium user information in the response, the handles to mention, and optionally the id of the status to reply to.
data TweetEntity Source #
Data type for tweets as they are returned
TweetEntity | |
|
type Timeline = [TweetEntity] Source #
Stores data like (name, text, favoriteCount, retweetCount)
Functions to sign API requests
signRequest :: FilePath -> Request -> IO Request Source #
Sign a request using your OAuth dev token. Uses the IO monad because signatures require a timestamp
Functions to generate a URL string from a Tweet
getProfile :: String -> Int -> FilePath -> IO (Either (ParseError Char Dec) Timeline) Source #
Get user profile given screen name and how many tweets to return
showProfile :: String -> Int -> Bool -> FilePath -> IO String Source #
Show a user profile given screen name, how many tweets to return (API maximum is 3200), and whether to print them in color.
showBest :: String -> Bool -> FilePath -> IO String Source #
Show the most successful tweets by a given user, given their screen name.
getDMs :: Show t => t -> FilePath -> IO (Either (ParseError Char Dec) Timeline) Source #
Get user's DMs.