swift - 我如何在 WordPress REST API(版本 2)中创建评论

标签 swift wordpress rest post comments

请帮帮我😒

how can i create comment in WordPress REST API (Version 2) with swift programmatically ? with ( UIButton and UIText )

我知道要获取评论(阅读评论)

但是我不知道怎么发评论 (从我的应用程序到我在 WordPress 中的网站)(POST)

谢谢

enter image description here

最佳答案

来自文档 here ,你需要对以下网址做一个POST请求

/wp/v2/comments

参数是这样的

enter image description here

为此,将按钮单击操作链接到您的代码

@IBAction func click(_ sender: Any) {

}

将 Alamofire API 导入您的项目。这个 API 被很好地用于 http 请求。您可以找到说明 here

最后这样做post请求。将这段代码放在上面的按钮 Action 函数中

let parameters: Parameters = [
    "author": "something",
    "email": "example@email.com",
    ...
]

Alamofire.request("UrlOfYourWebSite", method: .post, parameters: parameters).responseJSON { (responseData) -> Void in
    // parse responseData.result.value
}

关于swift - 我如何在 WordPress REST API(版本 2)中创建评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45009336/

相关文章:

swift - 如何快速更新 UIView

html - 我正在将 HTML 转换为 Wordpress : Content on page non-cooporative

wordpress - 如何包含paypal手续费

javascript - 在 Swift 中循环遍历 JavaScript 元素,WKWebView

ios - 如何使用 AVCapturePhotoOutput

c# - 如何在 Mono 上安装 RESTful WCF Web 服务 (.svc)?

python - 为什么我不能得到这个简单的 Python 字典的键/值对?

java - 如何在我的安卓设备上实现推送通知

swift - 无法等待 MKDirections.calculate 的结果,取而代之的是 nil

php - 获取并显示 WooCommerce 中产品属性的值