EVWordPressAPIWordPress (Jetpack) API 的 Swift 实现
EVWordPressAPI 是一个 WordPress (Jetpack) API 的 Swift 实现。
如何使用 EVWordPressAPI:
下面是一个简单调用的代码示例:
let api = EVWordPressAPI(baseUrl: "https://public-api.wordpress.com/rest/v1.1", site: "evict.nl") api.posts([.number(19)]) { posts in // now use the posts object }
EVWordPressAPI 也支持 API 调用(需要身份认证),这是一个代码示例:
let wordpressOauth2Settings = Oauth2Settings( baseURL: "https://public-api.wordpress.com/rest/v1.1", authorizeURL: "https://public-api.wordpress.com/oauth2/authorize", tokenURL: "https://public-api.wordpress.com/oauth2/token", redirectURL: "alamofireoauth2://wordpress/oauth_callback", clientID: "????????????", clientSecret: "????????????" ) let api = EVWordPressAPI(wordpressOauth2Settings: self.wordpressOauth2Settings, site: "evict.nl") api.users(self, parameters:[.number(19), .authors_only(false)]) { users in // now use the users object }
评论