HuntingKitProductHunt API 封裝器
HuntingKit 是 Product Hunt API 封裝器。
使用示例:
開始之前,先讓你的 app 取得授權(quán)證書。
let authenticationRequest = ProductHunt.Endpoint.ClientToken(id: "your-clientId", secret: "your-clientSecret")
ProductHunt.sendRequest(authenticationRequest) { response in
switch response {
case .Success(let box):
// At this point HuntingKit has stored the credentials in your keychain, you are free to use any other endpoint available. You also have access to the `AccessToken` yourself.
case .Failure(let box):
// Handle your errors
}
}
得到權(quán)限后,就可以獲取今天的所有產(chǎn)品。
let request = ProductHunt.Endpoint.Posts(from: .Today)
ProductHunt.sendRequest(request) { [unowned self] response in
switch response {
case .Success(let box):
// By now you have the array of Posts (products) available to you
case .Failure(let box):
// Handle your errors
}
}
評(píng)論
圖片
表情
