javascript - Unsplash API 触发下载
问题描述
我正在遵循 Unsplash 文档中的触发指南。所以终点是:
GET /photos/:id/download
这是照片的示例响应:
{
"id": "LBI7cgq3pbM",
"width": 5245,
"height": 3497,
"color": "#60544D",
"urls": { ... },
"user": { ... },
"links": {
"self": "https://api.unsplash.com/photos/LBI7cgq3pbM",
"html": "https://unsplash.com/photos/LBI7cgq3pbM",
"download": "https://unsplash.com/photos/LBI7cgq3pbM/download", // don't use this property
"download_location": "https://api.unsplash.com/photos/LBI7cgq3pbM/download?ixid=MnwxMTc4ODl8MHwxfHNlYXJjaHwxfHxwdXBweXxlbnwwfHx8fDE2MTc3NTA2MTM" // use this one ;)
}
}
“确保包含 URL 中包含的任何查询参数(如 ixid)。”
所以我的问题是什么是价值 odixid=MnwxMTc4ODl8MHwxfHNlYXJjaHwxfHxwdXBweXxlbnwwfHx8fDE2MTc3NTA2MTM
以及如何获得它?
解决方案
尝试以下
const ixid = new URLSearchParams(
new URL("https://api.unsplash.com/photos/LBI7cgq3pbM/download?ixid=MnwxMTc4ODl8MHwxfHNlYXJjaHwxfHxwdXBweXxlbnwwfHx8fDE2MTc3NTA2MTM").search
).get("ixid");
console.log(ixid);
推荐阅读
- azure-active-directory - 向 Azure B2C 登录 url 添加其他查询参数
- laravel - Laravel 中的 Job、Queue 和 Worker 有什么区别?
- python - Zappa:运行 lambda 函数时出现问题
- sql - 如何优化此查询以删除另一个表中没有对应 ID 的记录?
- javascript - 如何将数据从 Web 应用程序(React)传递到 chrome 扩展(开发面板)
- python - 保存时如何用计数命名文件?
- linux - 将安装 docker 客户端二进制文件从 MacOS 绑定到 docker-dind 映像
- python - 无法读取所有 HTML(网页抓取)
- python - 在 Python 中导入类的全局实例
- sql - 如何在不使用 knex.raw() 的情况下使用 knex.js 从 SQL Server 连接两列