MastodonClient 1.0.1

MastodonClient 1.0.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2017 年 4 月
SwiftSwift 版本3.0
SPM支持 SPM

Marcus Kida 维护。



 
依赖
Moya/RxSwift~> 8.0.3
Moya-Gloss/RxSwift~> 2.0.0
 

  • 作者
  • git

如何使用

此客户端旨在连接到任何 Mastodon 实例并与它交互。截至撰写本文时(2017 年 4 月 8 日),Moya Providers 的功能已完整实现 tootsuite/mastodon

MastodonClient 包含一些便利方法来创建应用(OAuth 客户端)并与 API 交互,但您目前应直接使用 Moya Targets(因为它们功能已完整)。

不要忘记在尝试使用任何 API 之前,通过在 Settings 单例中设置它来设置您 Mastodon 的基本 URL

Settings.shared.baseURL = NSURL(string: "https://mastodon.social")!

假设您有一个 OAuth 客户端

let app = App(clientId: "", clientSecret: "")

登录就像这样简单

RxMoyaProvider<Mastodon.OAuth>()
.request(.authenticate(app, username, password))
.mapObject(type: AccessToken.self)
.subscribe { even in  }

如果没有登录失败,并且您已获取到 AccessToken,则可以自由使用所有其他 API,例如获取您的主时间线

RxMoyaProvider<Mastodon.Timelines>(plugins: [AccessTokenPlugin(token: accessToken.token)])
.request(.home)
.mapArray(type: Status.self)
.subscribe { even in  }

要求

  • Xcode 8.3 / Swift 3.1
  • Moya/RxSwift
  • Moya-Gloss/RxSwift

安装

MastodonClient 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "MastodonClient"

作者

Marcus Kida [email protected]

许可证

MastodonClient 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。