rfreebern / giphy-php
A library implementing access to the Giphy API.
Installs: 79 942
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 1
Open Issues: 0
This package is not auto-updated.
Last update: 2024-12-21 16:51:52 UTC
README
A library providing a PHP interface to the Giphy API.
Installation
composer require rfreebern/giphy-php
Example
There is a file named giphy
in the bin
directory. Use it like this:
$ ./bin/giphy whiskey
GIF Usage
$giphy = new \rfreebern\Giphy();
$result = $giphy->random('whiskey');
print $result->data->image_original_url;
By default, the constructor uses the shared beta API key, but if you have a key of your own you can pass it as an argument:
$giphy = new \rfreebern\Giphy($my_giphy_api_key);
In general, the methods in the Giphy
class reflect the endpoints of the
Giphy API, and take the same arguments.
search($query, $limit = 25, $offset = 0)
Searches for gifs matching $query
.
getByID($id)
Fetches a specific GIF by its Giphy ID.
getByIDs(array $ids)
Fetches one or more specific GIFs by their Giphy IDs.
translate($query)
Translates a query to a matching GIF. See the docs for more information.
random($tag = null)
Fetches a random GIF, optionally matching the given tag.
trending($limit = 25)
Fetches a list of trending GIFs.
Sticker Usage
$sticker = new \rfreebern\Sticker();
$result = $sticker->random('whiskey');
print $result->data->image_original_url;
By default, the constructor uses the shared beta API key, but if you have a key of your own you can pass it as an argument:
$giphy = new \rfreebern\Giphy($my_giphy_api_key);
In general, the methods in the Giphy
class reflect the endpoints of the
Giphy API, and take the same arguments.
search($query, $limit = 25, $offset = 0)
Searches for stickers matching $query
.
translate($query)
Translates a query to a matching sticker. See the docs for more information.
random($tag = null)
Fetches a random sticker, optionally matching the given tag.
trending($limit = 25)
Fetches a list of trending stickers.
Credits
- This library was created by Ryan Freebern / @rfreebern.