{"id":18156211,"url":"https://github.com/xzakota/wordpresssdk","last_synced_at":"2026-04-24T16:06:53.972Z","repository":{"id":258475727,"uuid":"873625385","full_name":"xzakota/WordPressSDK","owner":"xzakota","description":"使用 kotlin 编写构建的 WP-SDK 库。| WP-SDK library built in Kotlin.","archived":false,"fork":false,"pushed_at":"2024-10-22T05:24:29.000Z","size":107,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T07:19:00.705Z","etag":null,"topics":["kotlin","wordpress"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xzakota.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T13:32:06.000Z","updated_at":"2025-01-15T13:47:57.000Z","dependencies_parsed_at":"2024-12-20T14:13:15.614Z","dependency_job_id":"750780e3-f2af-4e11-a415-1ff2567a7931","html_url":"https://github.com/xzakota/WordPressSDK","commit_stats":null,"previous_names":["xzakota/wordpresssdk"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xzakota%2FWordPressSDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xzakota%2FWordPressSDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xzakota%2FWordPressSDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xzakota%2FWordPressSDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xzakota","download_url":"https://codeload.github.com/xzakota/WordPressSDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247578618,"owners_count":20961270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","wordpress"],"created_at":"2024-11-02T05:05:44.917Z","updated_at":"2026-04-24T16:06:48.933Z","avatar_url":"https://github.com/xzakota.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"##### [📖 English Documentation](README_EN.md) | 📖 中文文档\n\n# WordPress SDK\n[![GitHub license](https://img.shields.io/github/license/xzakota/WordPressSDK?color=blue)](https://github.com/xzakota/WordPressSDK/blob/main/LICENSE)\n[![GitHub release](https://img.shields.io/github/v/release/xzakota/WordPressSDK?display_name=release\u0026logo=github\u0026color=green)](https://github.com/xzakota/WordPressSDK/releases)\n\n使用 kotlin 编写构建的 WP-SDK 库，暂时只支持 [Application Passwords](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#basic-authentication-with-application-passwords) 验证。\n\n# 依赖\n`Maven`:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.xzakota.wordpress\u003c/groupId\u003e\n    \u003cartifactId\u003esdk-kt\u003c/artifactId\u003e\n    \u003cversion\u003e${version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n`Gradle`:\n```groovy\ndependencies {\n    implementation 'com.xzakota.wordpress:sdk-kt:${version}'\n}\n```\n\n# 使用\n`Java`:\n```java\nWPClient client = new WPClient(server, new Authentication(username, appPwd));\n// 正常连接\nclient.connect();\n// 连接并测试，未通过测试将抛出异常\n// client.connectTest();\n\n// 发送请求\n// ...\n\n// 断开连接\nclient.disconnect();\n```\n\n`Kotlin`:\n```kotlin\nval client = WPClient(server, Authentication(username, appPwd))\n// 正常连接\nclient.connect()\n// 连接并测试，未通过测试将抛出异常\n// client.connectTest()\n\n// 发送请求\n// ...\n\n// 断开连接\nclient.disconnect()\n```\n\n## 页面操作\n`Java`:\n```java\nclient.request().pages(router -\u003e {\n    List\u003cPage\u003e pages = router.list();\n    println(\"List of Page: \");\n    println(pages);\n\n    Page page = new Page();\n    page.setTitle(new RenderedField(\"New page title\"));\n    page.setContent(new RenderedField(\"New page content\"));\n\n    Page createdPage = router.create(page);\n    if (createdPage != null) {\n        println(\"Created page id: \" + createdPage.getId());\n    }\n});\n```\n\n`Kotlin`:\n```kotlin\nclient.request().pages { router -\u003e\n    val pages = router.list()\n    println(\"List of Page: \")\n    println(pages)\n\n    router.create(Page().apply {\n        title = RenderedField(\"New page title\")\n        content = RenderedField(\"New page content\")\n    })?.let { createdPage -\u003e\n        println(\"Created page id: \" + createdPage.id)\n    }\n}\n```\n\n## 文章操作\n`Java`:\n```java\nclient.request().posts(router -\u003e {\n    Post post = router.retrieveById(1L);\n    if (post != null) {\n        println(\"Post with ID 1: $post\");\n\n        post.setPassword(\"123456\");\n        if (post.getId() != null) {\n            router.updateById(post.getId(), post);\n        }\n    } else {\n        println(\"No post with ID 1.\");\n    }\n});\n```\n\n`Kotlin`:\n```kotlin\nclient.request().posts { router -\u003e\n    val post = router.retrieveById(1L)\n    if (post != null) {\n        println(\"Post with ID 1: $post\")\n\n        post.password = \"123456\"\n        if (post.id != null) {\n            router.updateById(post.id!!, post)\n        }\n    } else {\n        println(\"No post with ID 1.\")\n    }\n}\n```\n\n## 其他操作\n其他使用请查看测试单元或浏览源代码\n1. [Java Test](https://github.com/xzakota/WordPressSDK/blob/master/SDK-KT/src/test/java/com/xzakota/wordpress/WPClientJTest.java)\n2. [Kotlin Test](https://github.com/xzakota/WordPressSDK/blob/master/SDK-KT/src/test/kotlin/com/xzakota/wordpress/WPClientTest.kt)\n\n# 其他衍生项目\n- File2Server(f2s): 计划开发，目前进度 20%。将本地 markdown、json 等文件解析上传至服务器，包括但不限于文章、页面、链接，字段丰富，管理简单。WordPress 平台则使用本项目(WP-SDK)。\n\n# 鸣谢\n- [Kotlin@JetBrains](https://github.com/JetBrains/kotlin)\n- [FASTJSON2@alibaba](https://github.com/alibaba/fastjson2)\n- [OkHttp@square](https://github.com/square/okhttp)\n- [wp-api-v2-client-java@Afrozaar](https://github.com/Afrozaar/wp-api-v2-client-java)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxzakota%2Fwordpresssdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxzakota%2Fwordpresssdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxzakota%2Fwordpresssdk/lists"}