EVWordPressAPIWordPress (Jetpack) API 的 Swift 實(shí)現(xiàn)
EVWordPressAPI 是一個(gè) WordPress (Jetpack) API 的 Swift 實(shí)現(xiàn)。
如何使用 EVWordPressAPI:
下面是一個(gè)簡(jiǎn)單調(diào)用的代碼示例:
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 調(diào)用(需要身份認(rèn)證),這是一個(gè)代碼示例:
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
}
評(píng)論
圖片
表情
