• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

syucream/hastodon: mastodon client module for Haskell

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

syucream/hastodon

开源软件地址(OpenSource Url):

https://github.com/syucream/hastodon

开源编程语言(OpenSource Language):

Haskell 100.0%

开源软件介绍(OpenSource Introduction):

Hastodon

Build Status Hackage-Deps

mastodon client module for Haskell

Quickstart

If you don't have client id and client secret, call postApps at first. (Alternatively, look in the web client, under the development section of your mastodon profile settings)

import Web.Hastodon
  appRes <- postApps "mastodon.social" "HastodonClientApp"
    case appRes of
      Right app -> do
        let clientId = oauthClientClientId app
        let clientSecret = oauthClientClientSecret app

Fill client id, client secret, the email address used to sign up for the instance and password, then call functions.

import Web.Hastodon

main :: IO ()
main = do
  let clientId = "???"
  let clientSecret = "???"
  let email = "???"
  let password = "???"
  maybeClient <- mkHastodonClient clientId clientSecret email password "mastodon.social"
  case maybeClient of
    Just client -> do
      timeline <- getAccountById client 93150
      print timeline
      result <- postStatus client "test toot from hastodon!"
      print result
    Nothing -> do
      putStrLn "Failed to log in.  Be careful regarding the spelling of your email and password."

Streaming

Streaming requires a little more ceremony, as well as familiarity with the Conduit library.

{-# LANGUAGE OverloadedStrings #-}
import Web.Hastodon
import Conduit
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  let inst = "mastodon.social"
  let token = "???" -- from /settings/applications
  let client = HastodonClient instance token -- or use mkHastodonClient as above
  runConduitRes $ streamUser client .| mapC showSR .| stdoutC
 where showSR (SNotification n) = "got notification: " `BS.append` (sb n) `BS.append` "\n"
       showSR (SUpdate s) = "got status: " `BS.append` (sb s) `BS.append` "\n"
       showSR (SDelete i) = "got delete: " `BS.append` (BS.pack i) `BS.append` "\n"
       showSR Thump = "got thump\n"
       sb v = BS.pack $ show v

Status of implementations

Mastodon APIs

  • GET /api/v1/accounts/:id
  • GET /api/v1/accounts/verify_credentials
  • PATCH /api/v1/accounts/update_credentials
  • GET /api/v1/accounts/:id/followers
  • GET /api/v1/accounts/:id/following
  • GET /api/v1/accounts/:id/statuses
  • POST /api/v1/accounts/:id/follow
  • POST /api/v1/accounts/:id/unfollow
  • POST /api/v1/accounts/:id/block
  • POST /api/v1/accounts/:id/unblock
  • POST /api/v1/accounts/:id/mute
  • POST /api/v1/accounts/:id/unmute
  • GET /api/v1/accounts/relationships
  • GET /api/v1/accounts/search
  • POST /api/v1/apps
  • GET /api/v1/blocks
  • GET /api/v1/favourites
  • GET /api/v1/follow_requests
  • POST /api/v1/follow_requests/:id/authorize
  • POST /api/v1/follow_requests/:id/reject
  • POST /api/v1/follows
  • GET /api/v1/instance
  • POST /api/v1/media
  • GET /api/v1/mutes
  • GET /api/v1/notifications
  • GET /api/v1/notifications/:id
  • POST /api/v1/notifications/clear
  • GET /api/v1/reports
  • POST /api/v1/reports
  • GET /api/v1/search
  • GET /api/v1/statuses/:id
  • GET /api/v1/statuses/:id/context
  • GET /api/v1/statuses/:id/card
  • GET /api/v1/statuses/:id/reblogged_by
  • GET /api/v1/statuses/:id/favourited_by
  • POST /api/v1/statuses
  • DELETE /api/v1/statuses/:id
  • POST /api/v1/statuses/:id/reblog
  • POST /api/v1/statuses/:id/unreblog
  • POST /api/v1/statuses/:id/favourite
  • POST /api/v1/statuses/:id/unfavourite
  • GET /api/v1/timelines/home
  • GET /api/v1/timelines/public
  • GET /api/v1/timelines/tag/:hashtag

Streaming

  • GET /api/v1/streaming/user
  • GET /api/v1/streaming/public
  • GET /api/v1/streaming/public/local
  • GET /api/v1/streaming/hashtag
  • GET /api/v1/streaming/list

Auth

  • the interface of POST /oauth/token

License

MIT

Author

Ryo Okubo [email protected]

Contributors




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap