PHP code example of devscast / pexels

1. Go to this page and download the library: Download devscast/pexels 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/ */

    

devscast / pexels example snippets


// ...
use Devscast\Pexels\Client;
// ...

$pexels = new Client(token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx');

$photos = $pexels->searchPhotos('Tigers');

// landscape photos only
$photos = $pexels->searchPhotos('Tigers', new SearchParameters(orientation: 'landscape', page: 2))

$photos = $pexels->curatedPhotos();

// paginated
$photos = $pexels->curatedPhotos(new PaginationParameters(page: 2, per_page: 60));

$photo = $pexels->photo(id: 11762029);

$videos = $pexels->searchVideos('Tigers');

// landscape videos only
$videos = $pexels->searchVideos('Tigers', new SearchParameters(orientation: 'landscape', page: 2))

$videos = $pexels->popularVideos();

// 30 secondes popular videos
$videos =  $pexels->popularVideos(new PopularVideosParameters(min_duration: 30, max_duration: 30));

$video = $pexels->video(id: 12593410);

$collections = $pexels->featuredCollections();

// paginated
$collections = $pexels->featuredCollection(new PaginationParameters(per_page: 80);

$collections = $pexels->collections();

$collection = $pexels->collection(id: 'someid');

// videos only
$collection = $pexels->collection(id: 'someid', new CollectionParameters(type: 'Videos'));