此项目的想法是创建一个易于使用、经过良好测试且文档完善的 Unsplash 客户端框架。在使用前,请务必阅读 Unsplash 的指南 & 署名。
计划实现与 Unsplash REST API 同等的功能
将以下内容添加到您的 Package
文件
dependencies: [
.package(url: "https://github.com/camiletti/UnsplashFramework.git", from: "0.4.0")
]
import UnsplashFramework
在进行任何请求之前,应设置 Unsplash 客户端凭证。 如果您尚未注册,请在此注册。
let credentials = UNCredentials(appID: "Your_AppID", secret: "Your_Secret"
let client = UNClient(with: credentials)
let photos = try await client.photos(fromUsername: "camiletti",
page: 1,
includeStats: true,
sortingBy: .latest)
let profile = try await client.publicProfile(forUsername: "camiletti")
// Searching photos
let photos = try await client.searchPhotos(query: "forest",
page: 1,
photosPerPage: 10,
orderedBy: .relevance,
orientation: .landscape)
// Searching collections
let collections = try await client.searchCollections(query: "jungle",
page: 1,
collectionsPerPage: 10)
// Searching for users
let users = try await client.searchUsers(query: "camiletti",
page: 1,
usersPerPage: 10)
UnsplashFramework 采用 MIT 许可证。
Copyright 2024 Pablo Camiletti
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.