测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可 | 自定义 |
发布最后发布 | 2016年8月 |
SPM支持 SPM | ✗ |
由Kyle Browning维护。
依赖关系 | |
Alamofire | >= 0 |
SwiftyJSON | >= 0 |
Drupal iOS SDK 是从任何 iOS 设备与 Drupal 通信的标准库集。它非常简单,基本上是 Alamofire 的包装。它结合了与 Drupal 通信时用到的最常用的命令,并为您处理会话管理。
DIOS 版本 | Drupal 版本 | 最小 iOS 目标 | 说明 |
---|---|---|---|
4.x | Drupal 8(Swift) | iOS 9.0 | |
3.x | Drupal 8(Obj-C) | iOS 7.0 | |
2.x | Drupal 6-7(Obj-C) | iOS 5.0 | 需要 Services 模块 |
在核心上,Drupal iOS SDK 被设计用来处理 Drupal 核心支持的所有内容。由于 8.x 尚处于起步阶段,随着 Drupal 旨在提高其 API 功能,越来越多的功能将变为可用。
未来,此项目将提供更多强大的功能,这些功能将使从 Swift 视角与 Drupal 一起工作变得更加容易,例如
创建一个 pod 文件(这将使您保持在 4.0 版本,这是 Drupal 8 特定的)
pod 'DIOS', '~> 4.0'
然后运行
pod install
dios.plist
diosurlkey
以指向您的域名以下代码将为您提供与Drupal站点的通信功能基线访问权限。
//Create an instance to use.
let dios = DIOS.sharedInstance
这将登录到该网站。
//set Username and password
dios.setUserNameAndPassword("kylebrowning", password: "password")
//we need an entity manager instance
let em = DIOSEntity()
let em = DIOSEntity()
//Get Node 36
em.get("node", entityId: "36") { (success, response, json, error) in
if (success) {
print(json)
} else {
print(error)
}
}
//build our node body
let body = [
"type": [
[
"target_id": "article"
]
],
"title": [
[
"value": "Hello World"
]
],
"body": [
[
"value": "How are you?"
]
]
]
//Create a new node.
em.post("node", params: body) { (success, response, json, error) in
if (success) {
print(response)
} else {
print(error)
}
}
//Update an existing node
em.patch("node", entityId: "36", params: body) { (success, response, json, error) in
if (success) {
//Extra error checking, but its not needed
if (response!.response?.statusCode == 201) {
print(json)
}
} else {
print(error)
}
}
//Delete an existing node
em.delete("node", entityId: "26") { (success, response, json, error) in
if (success) {
print(response)
} else {
print(error)
}
}