测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最新发行 | 2016 年 4 月 |
SPM支持 SPM | ✗ |
由 squiffy 维护。
依赖 | |
Alamofire | ~> 3.0 |
SwiftyJSON | ~> 2.3 |
p2.OAuth2 | ~> 2.2.3 |
请注意,该项目仍在开发中。许多端点尚未实现。这个库尚未有单元测试,一些文档也缺失。目前,AlienKit 只能处理“仅应用程序”授权。这意味着您可以通过 OAuth 访问 Reddit API,但不能在 Reddit 用户上下文中操作。用户授权最终还会加入。
AlienKit 的一个目标是易于使用。
与 Reddit 通信的第一步是获取一个应用 ID。您可以在 这里 获取。
在您开始使用 AlienKit 之前,您必须将以下行包括在您使用 AlienKit 的所有文件中
import AlienKit
一旦获得了应用 ID,您就可以使用该应用 ID 进行 OAuth 授权。要使用“仅应用程序”认证,可以使用以下代码。请确保使用您的应用 ID。
let client = UserlessClient(id: "my_app_id")
现在您有了 UserlessClient
对象,您可以使用 AlienKit 进行授权
client.authorize({
print("Successfully authorized!")
}, failure: { error in
print("authorization failed: \(error)")
})
用排序和过滤检索 subreReddit 中的帖子
client.getPostsFrom("swift", sortFilter: (.Top, .Week), success: { listing in
for thing in listing.things {
if let link = thing as? Link {
print(link.title)
}
}
}, failure: {
print("cant get posts")
})
用排序检索评论树
client.getCommentsFor(someLinkPost, sort: .Top, success: { listing in
for thing in listing.things {
if let comment = thing as? Comment {
// replies are in comment.replies as a "Listing" object
print(comment.body)
}
}
}, failure: {
print("cant get comments")
})
目前就是这样!稍后再来看更多。
AlienKit 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'AlienKit'
该项目正在使用名为 gitflow 的 git 工作流程开发。因此,在贡献时,请在 develop
分支上工作。
AlienKit 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。