zoonman / pixabay-php-api
PixabayClient is a PHP HTTP client library to access Pixabay's API
Installs: 48 926
Dependents: 1
Suggesters: 0
Security: 0
Stars: 30
Watchers: 4
Forks: 19
Open Issues: 0
Requires
- php: >=7.1.0
- ext-json: *
- guzzlehttp/guzzle: ^6.2|^7.0.0
Requires (Dev)
- phpunit/phpunit: ^7.0.0|^8.0.0|^9.0.0|^10.0.0
README
This is unofficial wrapper for Pixabay RESTful API for searching and retrieving Pixabay public domain images.
Installing via Composer
The recommended way to install Pixabay PHP Client is through Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of Pixabay PHP Client:
composer require zoonman/pixabay-php-api
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
Documentation
Compatible with PHP verisons:
- 7.2+
- 8
- hhvm
- nightly
See current build status above.
Usage example
<?php // wire the Composer Autoloader require_once 'vendor/autoload.php'; // instantiate the API Client // sign up for Pixabay service to get the correct API key $pixabayClient = new \Pixabay\PixabayClient([ 'key' => 'yourPixabayKey' ]); // run simplest possible query against the API $results = $pixabayClient->get(['q' => 'nature'], true); // show the results var_dump($results); // to get images use $results = $object->getImages(['q' => 'flowers', 'per_page' => 3], true); var_dump($results); // to get videos use $results = $object->getVideos(['q' => 'smile', 'per_page' => 3], true); var_dump($results);
To obtain your keys go to https://pixabay.com/api/docs/
More information can be found in the online documentation at https://www.zoonman.com/projects/pixabay/