twitter-conduit-0.0.6: Twitter API package with conduit interface and Streaming API support.

Safe HaskellNone
LanguageHaskell98

Web.Twitter.Conduit.Api

Contents

Synopsis

Search

searchTweets Source

Arguments

:: Text

search string

-> APIRequest SearchTweets (SearchResult [SearchStatus]) 

Returns search query.

You can perform a search query using call:

res <- call (searchTweets "search text")
liftIO . print $ res ^. searchResultStatuses
>>> searchTweets "search text"
APIRequestGet "https://api.twitter.com/1.1/search/tweets.json" [("q","search text")]
>>> searchTweets "search text" & lang ?~ "ja" & count ?~ 100
APIRequestGet "https://api.twitter.com/1.1/search/tweets.json" [("count","100"),("lang","ja"),("q","search text")]

search Source

Arguments

:: Text

search string

-> APIRequest SearchTweets (SearchResult [SearchStatus]) 

Alias of searchTweets, for backward compatibility

Direct Messages

directMessages :: APIRequest DirectMessages [DirectMessage] Source

Returns query data which asks recent direct messages sent to the authenticating user.

You can perform a query using call:

res <- call $ directMessages & count ?~ 100
>>> directMessages
APIRequestGet "https://api.twitter.com/1.1/direct_messages.json" []
>>> directMessages & count ?~ 100
APIRequestGet "https://api.twitter.com/1.1/direct_messages.json" [("count","100")]

directMessagesSent :: APIRequest DirectMessagesSent [DirectMessage] Source

Returns query data which asks recent direct messages sent by the authenticating user.

You can perform a query using call:

res <- call $ directMessagesSent & count ?~ 100
>>> directMessagesSent
APIRequestGet "https://api.twitter.com/1.1/direct_messages/sent.json" []
>>> directMessagesSent & count ?~ 100
APIRequestGet "https://api.twitter.com/1.1/direct_messages/sent.json" [("count","100")]

directMessagesShow :: StatusId -> APIRequest DirectMessagesShow DirectMessage Source

Returns query data which asks a single direct message, specified by an id parameter.

You can perform a query using call:

res <- call $ directMessagesShow 1234567890
>>> directMessagesShow 1234567890
APIRequestGet "https://api.twitter.com/1.1/direct_messages/show.json" [("id","1234567890")]

directMessagesDestroy :: StatusId -> APIRequest DirectMessagesDestroy DirectMessage Source

Returns post data which destroys the direct message specified in the required ID parameter.

You can perform a query using call:

res <- call $ directMessagesDestroy 1234567890
>>> directMessagesDestroy 1234567890
APIRequestPost "https://api.twitter.com/1.1/direct_messages/destroy.json" [("id","1234567890")]

directMessagesNew :: UserParam -> Text -> APIRequest DirectMessagesNew DirectMessage Source

Returns post data which sends a new direct message to the specified user from the authenticating user.

You can perform a post using call:

res <- call $ directMessagesNew (ScreenNameParam "thimura") "Hello DM"
>>> directMessagesNew (ScreenNameParam "thimura") "Hello DM"
APIRequestPost "https://api.twitter.com/1.1/direct_messages/new.json" [("text","Hello DM"),("screen_name","thimura")]
>>> directMessagesNew (UserIdParam 69179963) "Hello thimura! by UserId"
APIRequestPost "https://api.twitter.com/1.1/direct_messages/new.json" [("text","Hello thimura! by UserId"),("user_id","69179963")]

Friends & Followers

friendshipsNoRetweetsIds :: APIRequest FriendshipsNoRetweetsIds [UserId] Source

Returns a collection of user_ids that the currently authenticated user does not want to receive retweets from.

You can perform a request using call:

res <- call $ friendshipsNoRetweetsIds
>>> friendshipsNoRetweetsIds
APIRequestGet "https://api.twitter.com/1.1/friendships/no_retweets/ids.json" []

friendsIds :: UserParam -> APIRequest FriendsIds (WithCursor IdsCursorKey UserId) Source

Returns query data which asks a collection of user IDs for every user the specified user is following.

You can perform a query using call:

res <- call $ friendsIds (ScreenNameParam "thimura")

Or, you can iterate with sourceWithCursor:

sourceWithCursor (friendsIds (ScreenNameParam "thimura")) $$ CL.consume
>>> friendsIds (ScreenNameParam "thimura")
APIRequestGet "https://api.twitter.com/1.1/friends/ids.json" [("screen_name","thimura")]
>>> friendsIds (ScreenNameParam "thimura") & count ?~ 5000
APIRequestGet "https://api.twitter.com/1.1/friends/ids.json" [("count","5000"),("screen_name","thimura")]

followersIds :: UserParam -> APIRequest FollowersIds (WithCursor IdsCursorKey UserId) Source

Returns query data which asks a collection of user IDs for every user following the specified user.

You can perform a query using call:

res <- call $ followersIds (ScreenNameParam "thimura")

Or, you can iterate with sourceWithCursor:

sourceWithCursor (followersIds (ScreenNameParam "thimura")) $$ CL.consume
>>> followersIds (ScreenNameParam "thimura")
APIRequestGet "https://api.twitter.com/1.1/followers/ids.json" [("screen_name","thimura")]
>>> followersIds (ScreenNameParam "thimura") & count ?~ 5000
APIRequestGet "https://api.twitter.com/1.1/followers/ids.json" [("count","5000"),("screen_name","thimura")]

friendshipsIncoming :: APIRequest FriendshipsIncoming (WithCursor IdsCursorKey UserId) Source

Returns a collection of numeric IDs for every user who has a pending request to follow the authenticating user.

You can perform a request by using call:

res <- call $ friendshipsIncoming

Or, you can iterate with sourceWithCursor:

sourceWithCursor friendshipsIncoming $$ CL.consume
>>> friendshipsIncoming
APIRequestGet "https://api.twitter.com/1.1/friendships/incoming.json" []

friendshipsOutgoing :: APIRequest FriendshipsOutgoing (WithCursor IdsCursorKey UserId) Source

Returns a collection of numeric IDs for every protected user for whom the authenticating user has a pending follow request.

You can perform a request by using call:

res <- call $ friendshipsOutgoing

Or, you can iterate with sourceWithCursor:

sourceWithCursor friendshipsOutgoing $$ CL.consume
>>> friendshipsOutgoing
APIRequestGet "https://api.twitter.com/1.1/friendships/outgoing.json" []

friendshipsCreate :: UserParam -> APIRequest FriendshipsCreate User Source

Returns post data which follows the user specified in the ID parameter.

You can perform request by using call:

res <- call $ friendshipsCreate (ScreenNameParam "thimura")
>>> friendshipsCreate (ScreenNameParam "thimura")
APIRequestPost "https://api.twitter.com/1.1/friendships/create.json" [("screen_name","thimura")]
>>> friendshipsCreate (UserIdParam 69179963)
APIRequestPost "https://api.twitter.com/1.1/friendships/create.json" [("user_id","69179963")]

friendshipsDestroy :: UserParam -> APIRequest FriendshipsDestroy User Source

Returns post data which follows the user specified in the ID parameter.

You can perform request by using call:

res <- call $ friendshipsDestroy (ScreenNameParam "thimura")
>>> friendshipsDestroy (ScreenNameParam "thimura")
APIRequestPost "https://api.twitter.com/1.1/friendships/destroy.json" [("screen_name","thimura")]
>>> friendshipsDestroy (UserIdParam 69179963)
APIRequestPost "https://api.twitter.com/1.1/friendships/destroy.json" [("user_id","69179963")]

friendsList :: UserParam -> APIRequest FriendsList (WithCursor UsersCursorKey User) Source

Returns query data which asks a cursored collection of user objects for every user the specified users is following.

You can perform request by using call:

res <- call $ friendsList (ScreenNameParam "thimura")

Or, you can iterate with sourceWithCursor:

sourceWithCursor (friendsList (ScreenNameParam "thimura")) $$ CL.consume
>>> friendsList (ScreenNameParam "thimura")
APIRequestGet "https://api.twitter.com/1.1/friends/list.json" [("screen_name","thimura")]
>>> friendsList (UserIdParam 69179963)
APIRequestGet "https://api.twitter.com/1.1/friends/list.json" [("user_id","69179963")]

followersList :: UserParam -> APIRequest FollowersList (WithCursor UsersCursorKey User) Source

Returns query data which asks a cursored collection of user objects for users following the specified user.

You can perform request by using call:

res <- call $ followersList (ScreenNameParam "thimura")

Or, you can iterate with sourceWithCursor:

sourceWithCursor (followersList (ScreenNameParam "thimura")) $$ CL.consume
>>> followersList (ScreenNameParam "thimura")
APIRequestGet "https://api.twitter.com/1.1/followers/list.json" [("screen_name","thimura")]
>>> followersList (UserIdParam 69179963)
APIRequestGet "https://api.twitter.com/1.1/followers/list.json" [("user_id","69179963")]

Users

accountVerifyCredentials :: APIRequest AccountVerifyCredentials User Source

Returns query data asks that the credential is valid.

You can perform request by using call:

res <- call $ accountVerifyCredentials
>>> accountVerifyCredentials
APIRequestGet "https://api.twitter.com/1.1/account/verify_credentials.json" []

usersLookup :: UserListParam -> APIRequest UsersLookup [User] Source

Returns query data asks user objects.

You can perform request by using call:

res <- call $ usersLookup (ScreenNameListParam ["thimura", "twitterapi"])
>>> usersLookup (ScreenNameListParam ["thimura", "twitterapi"])
APIRequestGet "https://api.twitter.com/1.1/users/lookup.json" [("screen_name","thimura,twitterapi")]

usersShow :: UserParam -> APIRequest UsersShow User Source

Returns query data asks the user specified by user id or screen name parameter.

You can perform request by using call:

res <- call $ usersShow (ScreenNameParam "thimura")
>>> usersShow (ScreenNameParam "thimura")
APIRequestGet "https://api.twitter.com/1.1/users/show.json" [("screen_name","thimura")]

Suggested Users

Favorites

favoritesList :: Maybe UserParam -> APIRequest FavoritesList [Status] Source

Returns the 20 most recent Tweets favorited by the specified user.

You can perform request by using call:

res <- call $ favoritesList (ScreenNameParam "thimura")
>>> favoritesList Nothing
APIRequestGet "https://api.twitter.com/1.1/favorites/list.json" []
>>> favoritesList (Just (ScreenNameParam "thimura"))
APIRequestGet "https://api.twitter.com/1.1/favorites/list.json" [("screen_name","thimura")]
>>> favoritesList (Just (UserIdParam 69179963))
APIRequestGet "https://api.twitter.com/1.1/favorites/list.json" [("user_id","69179963")]

favoritesDestroy :: StatusId -> APIRequest FavoritesDestroy Status Source

Returns post data unfavorites the status specified in the ID paramter as the authenticating user.

You can perform request by using call:

res <- call $ favoritesDestroy 1234567890
>>> favoritesDestroy 1234567890
APIRequestPost "https://api.twitter.com/1.1/favorites/destroy.json" [("id","1234567890")]

favoritesCreate :: StatusId -> APIRequest FavoritesCreate Status Source

Returns post data which favorites the status specified in the ID parameter as the authenticating user.

You can perform request by using call:

res <- call $ favoritesCreate 1234567890
>>> favoritesCreate 1234567890
APIRequestPost "https://api.twitter.com/1.1/favorites/create.json" [("id","1234567890")]

Lists

listsStatuses :: ListParam -> APIRequest ListsStatuses [Status] Source

Returns the query parameter which fetches a timeline of tweets authored by members of the specified list.

You can perform request by using call:

res <- call $ listsStatuses (ListNameParam "thimura/haskell")

If you need more statuses, you can obtain those by using sourceWithMaxId: res <- sourceWithMaxId (listsStatuses (ListNameParam "thimura/haskell") & count ?~ 200) $$ CL.take 1000

>>> listsStatuses (ListNameParam "thimura/haskell")
APIRequestGet "https://api.twitter.com/1.1/lists/statuses.json" [("slug","haskell"),("owner_screen_name","thimura")]
>>> listsStatuses (ListIdParam 20849097)
APIRequestGet "https://api.twitter.com/1.1/lists/statuses.json" [("list_id","20849097")]

listsMembersDestroy :: ListParam -> UserParam -> APIRequest ListsMembersDestroy List Source

Returns the post parameter which removes the specified member from the list.

You can perform request by using call:

res <- call $ listsMembersDestroy (ListNameParam "thimura/haskell") (ScreenNameParam "thimura")
>>> listsMembersDestroy (ListNameParam "thimura/haskell") (ScreenNameParam "thimura")
APIRequestPost "https://api.twitter.com/1.1/lists/members/destroy.json" [("slug","haskell"),("owner_screen_name","thimura"),("screen_name","thimura")]
>>> listsMembersDestroy (ListIdParam 20849097) (UserIdParam 69179963)
APIRequestPost "https://api.twitter.com/1.1/lists/members/destroy.json" [("list_id","20849097"),("user_id","69179963")]

listsMemberships :: Maybe UserParam -> APIRequest ListsMemberships (WithCursor ListsCursorKey List) Source

Returns the request parameters which asks the lists the specified user has been added to. If UserParam are not provided, the memberships for the authenticating user are returned.

You can perform request by using call:

res <- call $ listsMemberships (ListNameParam "thimura/haskell")
>>> listsMemberships Nothing
APIRequestGet "https://api.twitter.com/1.1/lists/memberships.json" []
>>> listsMemberships (Just (ScreenNameParam "thimura"))
APIRequestGet "https://api.twitter.com/1.1/lists/memberships.json" [("screen_name","thimura")]
>>> listsMemberships (Just (UserIdParam 69179963))
APIRequestGet "https://api.twitter.com/1.1/lists/memberships.json" [("user_id","69179963")]

listsSubscribers :: ListParam -> APIRequest ListsSubscribers (WithCursor UsersCursorKey User) Source

Returns the request parameter which asks the subscribers of the specified list.

You can perform request by using call:

res <- call $ listsSubscribers (ListNameParam "thimura/haskell")
>>> listsSubscribers (ListNameParam "thimura/haskell")
APIRequestGet "https://api.twitter.com/1.1/lists/subscribers.json" [("slug","haskell"),("owner_screen_name","thimura")]
>>> listsSubscribers (ListIdParam 20849097)
APIRequestGet "https://api.twitter.com/1.1/lists/subscribers.json" [("list_id","20849097")]

listsMembers :: ListParam -> APIRequest ListsMembers (WithCursor UsersCursorKey User) Source

Returns query data asks the members of the specified list.

You can perform request by using call:

res <- call $ listsMembers (ListNameParam "thimura/haskell")
>>> listsMembers (ListNameParam "thimura/haskell")
APIRequestGet "https://api.twitter.com/1.1/lists/members.json" [("slug","haskell"),("owner_screen_name","thimura")]
>>> listsMembers (ListIdParam 20849097)
APIRequestGet "https://api.twitter.com/1.1/lists/members.json" [("list_id","20849097")]

listsMembersCreate :: ListParam -> UserParam -> APIRequest ListsMembersCreate List Source

Returns the post parameter which adds a member to a list.

You can perform request by using call:

res <- call $ listsMembersCreate (ListNameParam "thimura/haskell") (ScreenNameParam "thimura")
>>> listsMembersCreate (ListNameParam "thimura/haskell") (ScreenNameParam "thimura")
APIRequestPost "https://api.twitter.com/1.1/lists/members/create.json" [("slug","haskell"),("owner_screen_name","thimura"),("screen_name","thimura")]
>>> listsMembersCreate (ListIdParam 20849097) (UserIdParam 69179963)
APIRequestPost "https://api.twitter.com/1.1/lists/members/create.json" [("list_id","20849097"),("user_id","69179963")]

listsDestroy :: ListParam -> APIRequest ListsDestroy List Source

Returns the post parameter which deletes the specified list.

You can perform request by using call:

res <- call $ listsDestroy (ListNameParam "thimura/haskell")
>>> listsDestroy (ListNameParam "thimura/haskell")
APIRequestPost "https://api.twitter.com/1.1/lists/destroy.json" [("slug","haskell"),("owner_screen_name","thimura")]
>>> listsDestroy (ListIdParam 20849097)
APIRequestPost "https://api.twitter.com/1.1/lists/destroy.json" [("list_id","20849097")]

listsUpdate Source

Arguments

:: ListParam 
-> Bool

is public

-> Maybe Text

description

-> APIRequest ListsUpdate List 

Returns the post parameter which updates the specified list.

You can perform request by using call:

res <- call $ listsUpdate (ListNameParam "thimura/haskell") True (Just Haskellers)
>>> listsUpdate (ListNameParam "thimura/haskell") True (Just "Haskellers")
APIRequestPost "https://api.twitter.com/1.1/lists/update.json" [("slug","haskell"),("owner_screen_name","thimura"),("description","Haskellers"),("mode","public")]

listsCreate Source

Arguments

:: Text

list name

-> Bool

whether public(True) or private(False)

-> Maybe Text

the description to give the list

-> APIRequest ListsCreate List 

Returns the post parameter which creates a new list for the authenticated user.

You can perform request by using call:

res <- call $ listsCreate (ListNameParam "thimura/haskell")
>>> listsCreate "haskell" True Nothing
APIRequestPost "https://api.twitter.com/1.1/lists/create.json" [("name","haskell"),("mode","public")]
>>> listsCreate "haskell" False Nothing
APIRequestPost "https://api.twitter.com/1.1/lists/create.json" [("name","haskell"),("mode","private")]
>>> listsCreate "haskell" True (Just "Haskellers")
APIRequestPost "https://api.twitter.com/1.1/lists/create.json" [("description","Haskellers"),("name","haskell"),("mode","public")]

listsShow :: ListParam -> APIRequest ListsShow List Source

Returns the request parameter which asks the specified list.

You can perform request by using call:

res <- call $ listsShow (ListNameParam "thimura/haskell")
>>> listsShow (ListNameParam "thimura/haskell")
APIRequestGet "https://api.twitter.com/1.1/lists/show.json" [("slug","haskell"),("owner_screen_name","thimura")]
>>> listsShow (ListIdParam 20849097)
APIRequestGet "https://api.twitter.com/1.1/lists/show.json" [("list_id","20849097")]

listsSubscriptions :: Maybe UserParam -> APIRequest ListsSubscriptions (WithCursor ListsCursorKey List) Source

Returns the request parameter which obtains a collection of the lists the specified user is subscribed to.

You can perform request by using call:

res <- call $ listsSubscriptions (ListNameParam "thimura/haskell")
>>> listsSubscriptions Nothing
APIRequestGet "https://api.twitter.com/1.1/lists/subscriptions.json" []
>>> listsSubscriptions (Just (ScreenNameParam "thimura"))
APIRequestGet "https://api.twitter.com/1.1/lists/subscriptions.json" [("screen_name","thimura")]
>>> listsSubscriptions (Just (UserIdParam 69179963))
APIRequestGet "https://api.twitter.com/1.1/lists/subscriptions.json" [("user_id","69179963")]

listsOwnerships :: Maybe UserParam -> APIRequest ListsOwnerships (WithCursor ListsCursorKey List) Source

Returns the request parameter which asks the lists owned by the specified Twitter user.

You can perform request by using call:

res <- call $ listsOwnerships (ListNameParam "thimura/haskell")
>>> listsOwnerships Nothing
APIRequestGet "https://api.twitter.com/1.1/lists/ownerships.json" []
>>> listsOwnerships (Just (ScreenNameParam "thimura"))
APIRequestGet "https://api.twitter.com/1.1/lists/ownerships.json" [("screen_name","thimura")]
>>> listsOwnerships (Just (UserIdParam 69179963))
APIRequestGet "https://api.twitter.com/1.1/lists/ownerships.json" [("user_id","69179963")]

Saved Searches

Places & Geo

media

mediaUpload :: MediaData -> APIRequest MediaUpload UploadedMedia Source

Upload media and returns the media data.

You can update your status with multiple media by calling mediaUpload and update successively.

First, you should upload media with mediaUpload:

res1 <- call $ mediaUpload (MediaFromFile "/path/to/upload/file1.png")
res2 <- call $ mediaUpload (MediaRequestBody "file2.png" "[.. file body ..]")

and then collect the resulting media IDs and update your status by calling update:

call $ update "Hello World" & mediaIds ?~ [mediaId res1, mediaId res2]

See: https://dev.twitter.com/docs/api/multiple-media-extended-entities

>>> mediaUpload (MediaFromFile "/home/test/test.png")
APIRequestPostMultipart "https://upload.twitter.com/1.1/media/upload.json" []