Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b37ac34
Showing
18 changed files
with
816 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
.DS_Store | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
|
||
before_script: | ||
- curl -s http://getcomposer.org/installer | php | ||
- php composer.phar install --dev | ||
|
||
script: phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Changelog | ||
========= | ||
|
||
## Laravel Giphy v0.1-alpha | ||
- Initial testing release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Hidde Beydals <hello@hidde.co> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
Laravel Giphy | ||
============= | ||
![LARAVEL GIPHY](https://media4.giphy.com/media/ES4Vcv8zWfIt2/giphy.gif) | ||
|
||
Laravel Giphy is a [Giphy API](https://api.giphy.com) wrapper for Laravel (and Lumen but ssh, don't tell anyone), providing an easy to access `Giphy` facade. | ||
|
||
## Installation | ||
To use this package without running in to trouble you will need PHP 5.5+ or HHVM 3.6+, and Composer. | ||
|
||
1. Get the latest version of Laravel Giphy, add the following line to your `composer.json` file | ||
|
||
````"hiddeco/laravel-giphy": "0.1.*@alpha"```` | ||
|
||
2. Run `composer update` or `composer install` | ||
|
||
3. Register the Laravel Giphy service provider in `config/app.php` by adding | ||
`'HiddeCo\Ghiphy\GiphyServiceProvider` to the providers key | ||
|
||
4. Add the `Giphy` facade to the `aliases` key: `'Giphy' => 'HiddeCo\Giphy\Facades\Giphy'` | ||
|
||
## Configuration | ||
The only configuration Laravel Giphy needs is a `GIPHY_API_KEY` in your `.env` file. A public beta key is available in the [Giphy API Documentation](https://github.com/giphy/GiphyAPI). | ||
|
||
*Note: On Laravel it is also possible to configure Laravel Giphy by running `php artisan config:publish` and adding your `apiKey` to `config/giphy.php`.* | ||
|
||
## Injecting `Giphy` | ||
Injecting `Giphy` in to a controller could not have been any easier. | ||
|
||
````php | ||
<?php | ||
|
||
class GifController extends BaseController { | ||
|
||
public function __construct(HiddeCo\Giphy\Giphy $giphy) | ||
{ | ||
|
||
$this->giphy = $giphy; | ||
|
||
} | ||
|
||
public function get($id) | ||
{ | ||
try | ||
{ | ||
|
||
return $this->giphy->gif()->random([ 'fmt' => 'html' ]); | ||
} | ||
catch (\Exception $e) | ||
{ | ||
|
||
return $e->getMessage(); | ||
} | ||
} | ||
} | ||
```` | ||
|
||
## The API | ||
Using this package to communicate with the Giphy API is fairly simple by using the `Giphy` facade. | ||
|
||
### Giphy: GIFs | ||
Do you want to find a sweet GIF based on a keyword, translate a keyword to just one GIF or just get a random GIF? It is all possible. | ||
|
||
#### Giphy::gif->search($query, $params = []) | ||
Searches all GIFs for the provided word or phrase and accepts 4 optional parameters as array. | ||
- **limit:** default 25 (max: 100) | ||
- **offset** | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
````php | ||
Giphy::gif()->search('code', [limit' => 10, 'offset' => 10, 'rating' => 'g', 'fmt' => 'html']); | ||
```` | ||
|
||
#### Gipgy::gif()->get($id) | ||
Returns JSON meta data about a GIF by id. | ||
````php | ||
Giphy::gif()->get('4hnQDVKVARZ6w'); | ||
```` | ||
|
||
#### Giphy::gif()->getMultiple($ids = []) | ||
Returns JSON meta data about mulitple GIFs by id. | ||
````php | ||
Giphy::gif()->getMultiple(['4hnQDVKVARZ6w', 'Ro2MgOxH9iaVG']); | ||
```` | ||
|
||
#### Giphy::gif()->translate($query, $params = []) | ||
Returns a GIF from the Giphy 'translation engine', enter a keyword and get a GIF translation back. Accepts 2 optional parameters. | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
````php | ||
Giphy::gif()->translate($query, ['rating' => 'g', 'fmt' => 'html']); | ||
```` | ||
|
||
#### Giphy::gif()->random($params = []) | ||
Returns a random GIF, limitation is possible by using the following optional parameters. | ||
- **tag**: get a random GIF based on the keyword | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
|
||
````php | ||
Giphy::gif()->random(['tag' => 'cats', 'rating' => 'g', 'fmt' => 'html']); | ||
```` | ||
|
||
#### Giphy::gif()->trending($params = []) | ||
Returns currently trending GIFs on the internet. Accepts 3 optional parameters. | ||
- **limit:** default 25 (max: 100) | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
|
||
````php | ||
Giphy::gif()->trending(['limit' => 100, 'rating' => 'pg', 'fmt' => 'html'); | ||
```` | ||
|
||
### Giphy: Stickers | ||
Giphy stickers are animated stickers (animated GIFs with transparent backgrounds). | ||
|
||
#### Giphy::sticker()->search($query, $params = []) | ||
Searches all sticker GIFs for the provided word or phrase and accepts 4 optional parameters as array. | ||
- **limit:** default 25 (max: 100) | ||
- **offset** | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
````php | ||
Giphy::sticker()->search('code', [limit' => 10, 'offset' => 10, 'rating' => 'g', 'fmt' => 'html']); | ||
```` | ||
|
||
#### Giphy::sticker()->translate($query, $params = []) | ||
Returns a sticker GIF from the Giphy 'translation engine', enter a keyword and get a sticker GIF translation back. Accepts 2 optional parameters. | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
````php | ||
Giphy::sticker()->translate($query, ['rating' => 'g', 'fmt' => 'html']); | ||
```` | ||
|
||
#### Giphy::sticker()->random($params = []) | ||
Returns a random sticker GIF, limitation is possible by using the following optional parameters. | ||
- **tag**: get a random GIF based on the keyword | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
|
||
````php | ||
Giphy::sticker()->random(['tag' => 'cats', 'rating' => 'g', 'fmt' => 'html]); | ||
```` | ||
|
||
#### Giphy::sticker()->trending($params = []) | ||
Returns currently trending sticker GIFs on the internet. Accepts 3 optional parameters. | ||
- **limit:** default 25 (max: 100) | ||
- **rating:** limit results by rating (y,g, pg, pg-13 or r) | ||
- **fmt:** returned format, json or html (default: json) | ||
|
||
````php | ||
Giphy::sticker()->trending(['limit' => 100, 'rating' => 'pg', 'fmt' => 'html']); | ||
```` | ||
|
||
## License | ||
Laravel Giphy is licensed under the [MIT License (MIT)](https://github.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "hiddeco/laravel-giphy", | ||
"description": "Giphy API wrapper for Laravel and Lumen based on Guzzle", | ||
"keywords": ["giphy", "api", "laravel"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Hidde Beydals", | ||
"email": "hello@hidde.co" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4.0", | ||
"illuminate/support": "5.0.*|5.1.*", | ||
"guzzlehttp/guzzle": "~5.0|~5.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"HiddeCo\\Giphy\\": "src/HiddeCo/Giphy" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Laravel Giphy Test Suite"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php namespace HiddeCo\Giphy\Contracts; | ||
|
||
/** | ||
* This file is a part of Laravel Giphy, | ||
* a Giphy API wrapper for Laravel and Lumen. | ||
* | ||
* @package HiddeCo\Giphy | ||
* @license MIT | ||
* @author Hidde Beydals <hello@hidde.co> | ||
* @version 0.1 | ||
*/ | ||
interface Client { | ||
|
||
/** | ||
* @param $endPoint | ||
* @param array $options | ||
* | ||
* @return mixed | ||
*/ | ||
public function get($endPoint, array $options = [ ]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php namespace HiddeCo\Giphy\Contracts; | ||
|
||
/** | ||
* This file is a part of Laravel Giphy, | ||
* a Giphy API wrapper for Laravel and Lumen. | ||
* | ||
* @package HiddeCo\Giphy | ||
* @license MIT | ||
* @author Hidde Beydals <hello@hidde.co> | ||
* @version 0.1 | ||
*/ | ||
|
||
interface Gif { | ||
|
||
/** | ||
* Searches for a GIF. | ||
* | ||
* @param $query | ||
* @param array $params | ||
* | ||
* @return mixed | ||
*/ | ||
public function search($query, array $params = [ ]); | ||
|
||
|
||
/** | ||
* Returns a GIF by id. | ||
* | ||
* @param $id | ||
* | ||
* @return mixed | ||
*/ | ||
public function get($id); | ||
|
||
|
||
/** | ||
* Returns multiple GIFs by their ids. | ||
* | ||
* @param array $ids | ||
* | ||
* @return mixed | ||
*/ | ||
public function getMultiple(array $ids); | ||
|
||
|
||
/** | ||
* Translates a string to a GIF and returns result. | ||
* | ||
* @param $query | ||
* @param array $params | ||
* | ||
* @return mixed | ||
*/ | ||
public function translate($query, array $params = [ ]); | ||
|
||
|
||
/** | ||
* Returns a random GIF. | ||
* | ||
* @param array $params | ||
* | ||
* @return mixed | ||
*/ | ||
public function random(array $params = [ ]); | ||
|
||
|
||
/** | ||
* Returns trending GIFs. | ||
* | ||
* @param array $params | ||
* | ||
* @return mixed | ||
*/ | ||
public function trending(array $params = [ ]); | ||
} |
Oops, something went wrong.