PHPackages                             dolphin.wang/unsplash-random-download - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. dolphin.wang/unsplash-random-download

ActiveLibrary[Image &amp; Media](/categories/media)

dolphin.wang/unsplash-random-download
=====================================

随机的从 Unsplash 网站下载图片到本地

v1.1.0(7y ago)132BSD-3-ClausePHP

Since Sep 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dolphin836/unsplash-random-download)[ Packagist](https://packagist.org/packages/dolphin.wang/unsplash-random-download)[ RSS](/packages/dolphinwang-unsplash-random-download/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (3)Used By (0)

随机的从 Unsplash 网站下载图片到本地

使用方法
----

[](#使用方法)

1. 注册 [Unsplash](https://unsplash.com) 账户；
2. 在 [开发者中心](https://unsplash.com/developers) 创建应用，并获取 Access Key；
3. 使用 Composer 进行安装

```
composer require dolphin.wang/unsplash-random-download

```

4. 按照以下方式引用，可参考 demo

```
require __DIR__ . '/vendor/autoload.php';

use Dolphin\Wang\Unsplash\Random;
// 设置 Unsplash Access Key，如果只需要下载单张图片设置一个 KEY 就可以了，如果需要开启自动下载任务，可以设置多个 KEY，程序会自动切换 KEY 来绕过 Unsplash 的接口请求限制。根据 Unsplash 的接口请求限制规则，建议添加 10 个或以上的 KEY。如果是生产版的应用则不需要设置多个。
$access_key_arr = [
    '',
    ''
];

$dir = 'pic';

$random = new Random($access_key_arr, $dir);
// 下载单张图片
var_dump($random->rand());
// 启动自动下载任务：注意 Unsplash API 的请求限制规则，测试版每小时 50 次，生产版每小时 5000 次，超过限制接口返回 403 错误
$random->run();
```

> 变量 `dir` 表示图片保存的文件夹（相对路径），可选，默认值为 `pic`，当然你需要先手动创建它，并且在 `Linux` 系统中设置为可写权限。

下载单张图片时返回的数据格式为：

```
{
	"code": 0,
	"error": "",
	"data": {
		"id": "jIECjqms_no"
	}
}
```

> 当 `code` 为 0 表示下载成功，不为 0 时表示下载失败，`error` 表示错误原因。

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity63

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2787d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3326916?v=4)[海兵大侠](/maintainers/dolphin836)[@dolphin836](https://github.com/dolphin836)

---

Tags

downloadphotophpunsplash

### Embed Badge

![Health badge](/badges/dolphinwang-unsplash-random-download/health.svg)

```
[![Health](https://phpackages.com/badges/dolphinwang-unsplash-random-download/health.svg)](https://phpackages.com/packages/dolphinwang-unsplash-random-download)
```

###  Alternatives

[opentok/opentok

OpenTok is a platform for creating real time streaming video applications, created by TokBox.

1413.0M10](/packages/opentok-opentok)[automattic/wistia-php

PHP wrapper for Wistia API

1431.9k](/packages/automattic-wistia-php)[daun/statamic-placeholders

Generate low-quality image placeholders for lazyloading Statamic assets

106.6k](/packages/daun-statamic-placeholders)[daun/statamic-mux

Seamless video encoding and streaming using Mux on Statamic sites

132.3k](/packages/daun-statamic-mux)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
