PHP code example of crewlabs / unsplash
1. Go to this page and download the library: Download crewlabs/unsplash library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
crewlabs / unsplash example snippets
Unsplash\HttpClient::init([
'applicationId' => 'YOUR ACCESS KEY',
'secret' => 'YOUR APPLICATION SECRET',
'callbackUrl' => 'https://your-application.com/oauth/callback',
'utmSource' => 'NAME OF YOUR APPLICATION'
]);
$scopes = ['public', 'write_user'];
Unsplash\HttpClient::$connection->getConnectionUrl($scopes);
Unsplash\HttpClient::$connection->generateToken($code);
$search = 'forest';
$page = 3;
$per_page = 15;
$orientation = 'landscape';
Unsplash\Search::photos($search, $page, $per_page, $orientation);
Unsplash\Search::collections($search, $page, $per_page);
Unsplash\Search::users($search, $page, $per_page);
Unsplash\Collection::all($page, $per_page);
$collection = Unsplash\Collection::find(integer $id);
$photos = $collection->photos($page, $per_page);
$collection = Unsplash\Collection::find($id);
$collection->related();
$collection = Unsplash\Collection::create($title);
$collection = Unsplash\Collection::find(int $id);
$collection->update(['private' => true])
$collection = Unsplash\Collection::find(int $id);
$collection->destroy()
$collection = Unsplash\Collection::find(int $id);
$collection->add(int $photo_id)
$collection = Unsplash\Collection::find(int $id);
$collection->remove(int $photo_id)
Unsplash\Photo::all($page, $per_page, $order_by);
Unsplash\Photo::find($id);
$photo = Unsplash\Photo::find(string $id)
$photo->update(array $parameters);
$photo = Unsplash\Photo::find(string $id);
$photo->photographer();
// Or apply some optional filters by passing a key value array of filters
$filters = [
'username' => 'andy_brunner',
'query' => 'coffee',
'w' => 100,
'h' => 100
];
Unsplash\Photo::random($filters);
$photo = Unsplash\Photo::find(string $id);
$photo->like();
$photo = Unsplash\Photo::find(string $id);
$photo->unlike();
$photo = Unsplash\Photo::find($id);
$photo->statistics('days', 7);
$photo = Unsplash\Photo::find();
$photo->download();
Unsplash\User::find($username)
Unsplash\User::portfolio($username)
$user = Unsplash\User::current();
$user = Unsplash\User::find($username);
$user->photos($page, $per_page);
$user = Unsplash\User::find($username);
$user->collections($page, $per_page);
$user = Unsplash\User::find($username);
$user->likes($page, $per_page, $order_by);
$user = Unsplash\User::current();
$user->update(['first_name' => 'Elliot', 'last_name' => 'Alderson']);
$user = Unsplash\User::find($id);
$user->statistics('days', 7);