Download the PHP package unsplash/unsplash without Composer

On this page you can find all versions of the php package unsplash/unsplash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
unsplash/unsplash
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package unsplash

PHP Unsplash Wrapper

Build Status

A PHP client for the Unsplash API.

Quick links to methods you're likely to care about:

Note: Every application must abide by the API Guidelines. Specifically, remember to hotlink images and trigger a download when appropriate.

Installation

unsplash-php uses Composer. To use it, require the library

Usage

Configuration

Before using, configure the client with your access key and secret. If you don't have an access key and secret, follow the steps from the Unsplash API to register your application.

Note: if you're just using actions that require the public permission scope, only the access key is required. Access key is entered as applicationId due to legacy reasons.

Note: if utmSource is omitted from $credentials a notice will be raised.

User Authorization workflow

If you need to access actions that are non-public on behalf of the user (i.e. uploading a photo to a specific account), you'll need to follow the user authentication workflow to access their data.

An example of this flow can be found in /examples/oauth-flow.php

Direct them to an authorization URL (configuring any scopes before generating the authorization URL):

Upon authorization, Unsplash will return to you an authentication code via your OAuth callback handler. Use it to generate an access token:

With the token you can now access any additional non-public actions available for the authorized user.

Permission Scopes

The current permission scopes defined by the Unsplash API are:


API methods

For more information about the responses for each call, refer to the official documentation.

Some parameters are identical across all methods:

param Description
$per_page Defines the number of objects per page. Default 10
$page Defines the offset page. Default 1

Note: The methods that return multiple objects return an ArrayObject, which acts like a normal stdClass.


Search

Photos

Retrieve a single page of photo results depending on search results.

Arguments

Argument Type Opt/Required
$search string Required
$page int Opt (Default: 1)
$per_page int Opt (Default: 10 / Maximum: 30)
$orientation string Opt (Default: null / Available: "landscape", "portrait", "squarish")
$collections string Opt (Default: null / If multiple, comma-separated)
$order_by string How to sort the photos. (Optional; default: relevant). Valid values are latest and relevant.

Example


Collections

Retrieve a single page of collection results depending on search results.

Arguments

Argument Type Opt/Required
$search string Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)

Example


Users

Retrieve a single page of user results depending on search results.

Arguments

Argument Type Opt/Required
$search string Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)

Example


Collections

Retrieve the list of collections.

Arguments

Argument Type Opt/Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)

Example


Unsplash\Collection::photos($page, $per_page)

Retrieve photos from a collection.

Note: You need to instantiate a collection object first.

Arguments

Argument Type Opt/Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)

Example


Unsplash\Collection::related($page, $per_page)

Retrieve list of featured collections.

Note You must instantiate a collection first

Arguments

Argument Type Opt/Required

Example


Unsplash\Collection::create($title, $description, $private)

Create a collection on the user's behalf.

Note: You need the write_collections permission scope

Arguments

Argument Type Opt/Required
$title string Required
$description string Opt (Default: '')
$private boolean Opt (Default: false)

Example


Unsplash\Collection::update($parameters)

Update a collection on the user's behalf.

Note: You need to instantiate a collection object first

Note: You need the write_collections permission scope

Arguments

Argument Type Opt/Required Note
$parameters array Required The following keys can be set in the array : title, description, private

Example


Unsplash\Collection::destroy()

Delete a collection on the user's behalf.

Note: You need to instantiate a collection object first

Note: You need the write_collections permission scope

Example


Unsplash\Collection::add($photo_id)

Add a photo in the collection on the user's behalf.

Note: You need to instantiate a collection object first

Note: You need the write_collections permission scope

Arguments

Argument Type Opt/Required
$photo_id integer Required

Example


Unsplash\Collection::remove($photo_id)

Remove a photo from the collection on the user's behalf.

Note: You need to instantiate a collection object first

Note: You need the write_collections permission scope

Arguments

Argument Type Opt/Required
$photo_id integer Required

Example


Photo

Unsplash\Photo::all($page, $per_page, $order_by)

Retrieve a list of photos.

Arguments

Argument Type Opt/Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)
$order_by string Opt (Default: latest / Available: oldest, popular)

Example


Unsplash\Photo::find($id)

Retrieve a specific photo.

Arguments

Argument Type Opt/Required
$id int Required

Example


Unsplash\Photo::update($parameters = [])

Post a photo on the user's behalf.

Note: You need the write_photos permission scope You need to instantiate the Photo object first

Arguments

Argument Type Opt/Required
$parameters array Required

Example


Unsplash\Photo::photographer()

Retrieve the photo's photographer.

Note: You need to instantiate a photo object first

Arguments

N/A

Example


Unsplash\Photo::random([featured => $value, username => $value, query => $value, w => $value, h => $value])

Retrieve a random photo from specified filters. For more information regarding filtering, refer to the Offical documentation.

Note: An array needs to be passed as a parameter.

Arguments

Argument Type Opt/Required
featured boolean Opt (Limit selection to featured photos)
username string Opt (Limit selection to a single user)
query string Opt (Limit selection to photos matching a search term)
w int Opt (Image width in pixels)
h int Opt (Image height in pixels)

Example


Unsplash\Photo::like()

Like a photo on the user's behalf.

Note: You need to instantiate a photo object first

Note: You need the like_photos permission scope

Arguments

N/A

Example


Unsplash\Photo::unlike()

Unlike a photo on the user's behalf.

Note: You need to instantiate a photo object first

Note: You need the like_photos permission scope

Arguments

N/A

Example


Unsplash\Photo::statistics(string $resolution, int $quantity)

Retrieve total number of downloads, views and likes of a single photo, as well as the historical breakdown of these stats in a specific timeframe (default is 30 days).

Note: You must instantiate a Photo object first

Arguments

Argument Type Opt/Required
resolution string Opt (Accepts only days currently)
quantity int Opt (Defaults to 30, can be between 1 and 30)

Example


Unsplash\Photo::download()

Trigger a download for a photo. This is needed to follow the 'trigger a download' API Guideline.

Note: You must instantiate a Photo object first

Arguments

Argument Type Opt/Required

Example


User

Unsplash\User::find($username)

Retrieve a user's information.

Arguments

Argument Type Opt/Required
$username string Required

Example


Unsplash\User::portfolio($username)

Retrieve a link to the user's portfolio page.

Arguments

Argument Type Opt/Required
$username string Required

Example


Unsplash\User::current()

Retrieve the user's private information.

Note: You need the read_user permission scope

Arguments

N/A

Example


Unsplash\User::photos($page, $per_page, $order_by)

Retrieve user's photos.

Note: You need to instantiate a user object first

Arguments

Argument Type Opt/Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)
$order_by string Opt (Default: latest / Available: oldest, popular)

Example


Unsplash\User::collections($page, $per_page)

Retrieve user's collections.

Note: You need to instantiate a user object first Note: You need the read_collections permission scope to retrieve user's private collections

Arguments

Argument Type Opt/Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)

Example


Unsplash\User::likes($page, $per_page, $order_by)

Retrieve user's collections.

Note: You need to instantiate a user object first

Arguments

Argument Type Opt/Required
$per_page int Opt (Default: 10 / Maximum: 30)
$page int Opt (Default: 1)
$order_by string Opt (Default: latest / Available: oldest, popular)

Example


Unsplash\User::update([$key => value])

Update current user's fields. Multiple fields can be passed in the array.

Note: You need to instantiate a user object first

Note: You need the write_user permission scope.

Arguments

Argument Type Opt/Required Note
$key string Required The following keys are accepted: username, first_name, last_name, email, url, location, bio, instagram_username
$value mixed required

Unsplash\User::statistics(string $resolution, int $quantity)

Retrieve total number of downloads, views and likes for a user, as well as the historical breakdown of these stats in a specific timeframe (default is 30 days).

Note: You must instantiate the User object first

Arguments

Argument Type Opt/Required
resolution string Opt (Accepts only days currently)
quantity int Opt (Defaults to 30, can be between 1 and 30)

Example


Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/unsplash/unsplash-php. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


All versions of unsplash with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3.0
guzzlehttp/guzzle Version ^6.3.0|^7.0
league/oauth2-client Version >=1.4.2
hughbertd/oauth2-unsplash Version >=1.0.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package unsplash/unsplash contains the following files

Loading the files please wait ....