Write a simple Twitter API client in Haskell. This client simply has to fetch and display Tweets that:
- Have been re-Tweeted at least once and
- Contain the hashtag #custserv
-
First, you must obtain consumer key and secret from Twitter Application Management page, and you have to set those values to the config json:
-
Create an application (fill in dummy data to the provided form)
-
Now you must prepare OAuth access token and secret
-
Under Key and Access Tokens tab. You will have Application Setting and Your access token generete them
-
Create a
config.json
file with the above details (sample given below).{ "apiKey": "<Consumer Key (API Key) in Application Setting>", "apiSecret": "<Consumer Secret (API Secret) in Application Setting>", "accessToken": "<Access Token in Your Access Token>", "accessTokenSecret": "<Access Token Secret in Your Access Token>" }
-
Run
stack build
(you may need to runstack setup
as well) -
Run
stack exec tw-custserv-exe
- It is a stack project so all the things specific to stack apply here as well.
src/Types
contain all the custom types.Config.hs
: the configuration object used to authenticate.Query.hs
: the query object (extend it if you want more functionality from queries)Tweets.hs
: Representation of a Tweet, Metadata accompnying a search query and The complete search response by twitter
src/TwitterAuth.hs
contains all the Oauth related functions.src/TwitterCustServ.hs
contains everythig else.
- User should be able to login with their credentials and not have to setup the config.json