2017 © Pedro Peláez
 

library giphy-and-stickers

A package that provides an interface between Laravel and Giphy API, includes Gifs and Stickers.

image

romeroqe/giphy-and-stickers

A package that provides an interface between Laravel and Giphy API, includes Gifs and Stickers.

  • Friday, March 16, 2018
  • by Romeroqe
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2,118 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Giphy and Stickers

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

A package that provides an interface between Laravel and Giphy API, includes Gifs and Stickers., (*2)

Installation

Composer

First, pull in the package through Composer., (*3)

``` php “require”: { ... "romeroqe/giphy-and-stickers": "dev-master" }, (*4)


And run composer:

$ composer update, (*5)


### Provider Once installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key. ``` php 'providers' => [ ... Romeroqe\Giphy\GiphyServiceProvider::class, Romeroqe\Giphy\StickersServiceProvider::class, ]

Facade

This package also ships with a facade which provides the static syntax. You can register the facade in the aliases key of your config/app.php file., (*6)

'aliases' => [
    ...
    'Giphy' => Romeroqe\Giphy\GiphyFacade::class,
    'Stickers' => Romeroqe\Giphy\StickersFacade::class,
]

Quick Examples

You can see the documentation for more information., (*7)

Parameters
  • q - search query term or phrase
  • s - search query term or phrase
  • limit - (optional) number of results to return, maximum 100. Default 25.
  • offset - (optional) results offset, defaults to 0.
  • rating - (optional) limit results to those rated (y,g, pg, pg-13 or r).
  • lang - (optional) specify default country for regional content; format is 2-letter ISO 639-1 country code. See list of supported langauges here

Endpoints

Gifs

Search all Giphy GIFs for a word or phrase. Punctuation will be stripped and ignored. On this case, $giphys is an array., (*8)

Method: Giphy::search($query, $limit = 25, $offset = 0, $rating = null, $lang = null), (*9)

$giphys = Giphy::search('cat');

foreach ($giphys->data as $giphy) {
    // Get id
    $giphy->id;

    // Get image original url
    $giphy->images->original->url;

    // Get image original mp4 url
    $giphy->images->original->mp4;

    //etc
}

You can do a dd($giphys) to see all attributes:, (*10)

{#162 ▼
  +"data": array:25 [▼
    0 => {#163 ▼
      +"type": "gif"
      +"id": "W80Y9y1XwiL84"
      +"slug": "gift-W80Y9y1XwiL84"
      +"url": "http://giphy.com/gifs/gift-W80Y9y1XwiL84"
      ...
    }
    1 => {#182 ▶}
    2 => {#202 ▶}
    ...

Translate

The translate API draws on search, but uses the Giphy "special sauce" to handle translating from one vocabulary to another., (*11)

Method: Giphy::translate($query, $rating = null, $lang = null), (*12)

$giphy= Giphy::translate('cat');

// Get id
$giphy->data->id;

// Get image original url
$giphy->data->images->original->url;

// Get image original mp4 url
$giphy->data->images->original->mp4;

//etc

You can do a dd($giphy) to see all attributes:, (*13)

{#162 ▼
  +"data": {#163 ▼
    +"type": "gif"
    +"id": "3oz8xQQP4ahKiyuxHy"
    ...
    +"images": {#165 ▼
      ...
      +"original": {#180 ▼
        +"url": "http://media3.giphy.com/media/3oz8xQQP4ahKiyuxHy/giphy.gif"
        +"width": "480"
        +"height": "352"
        +"size": "3795005"
        +"frames": "33"
        +"mp4": "http://media3.giphy.com/media/3oz8xQQP4ahKiyuxHy/giphy.mp4"
        +"mp4_size": "132229"
        +"webp": "http://media3.giphy.com/media/3oz8xQQP4ahKiyuxHy/giphy.webp"
        +"webp_size": "756840"
      }
      ...

Fetch GIFs currently trending online. On this case, $giphys is an array., (*14)

Method: Giphy::trending($limit = 25, $rating = null), (*15)

$giphys = Giphy::trending();

foreach ($giphys->data as $giphy) {
    // Get id
    $giphy->id;

    // Get image original url
    $giphy->images->original->url;

    // Get image original mp4 url
    $giphy->images->original->mp4;

    //etc
}

You can do a dd($giphys) to see all attributes:, (*16)

{#162 ▼
  +"data": array:25 [▼
    0 => {#163 ▼
      +"type": "gif"
      +"id": "l2SqiAELInKQ8rF0Q"
      +"slug": "2dopequeens-podcast-2-dope-queens-l2SqiAELInKQ8rF0Q"
      +"url": "http://giphy.com/gifs/2dopequeens-podcast-2-dope-queens-l2SqiAELInKQ8rF0Q"
      ...
    }
    1 => {#183 ▶}
    2 => {#203 ▶}
    ...

Random

Returns a random GIF, limited by tag., (*17)

Method: Giphy::random($query, $rating = null), (*18)

$giphy = Giphy::random('cat');

// Get id
$giphy->data->id;

// Get image original url
$giphy->data->image_original_url;

// Get image mp4 url
$giphy->data->image_mp4_url;

//etc

You can do a dd($giphy) to see all attributes:, (*19)

{#162 ▼
  +"data": {#163 ▼
    +"type": "gif"
    +"id": "qbpRDgYI5JoKk"
    +"url": "http://giphy.com/gifs/cat-qbpRDgYI5JoKk"
    +"image_original_url": "https://media0.giphy.com/media/qbpRDgYI5JoKk/giphy.gif"
    ...
  }
  +"meta": {#164 ▼
    +"status": 200
    +"msg": "OK"
  }
}

By ID

Returns meta data about a GIF, by GIF id., (*20)

Method: Giphy::getByID($id), (*21)

$giphy= Giphy::getByID('qbpRDgYI5JoKk');

// Get id
$giphy->data->id;

// Get image original url
$giphy->data->images->original->url;

// Get image original mp4 url
$giphy->data->images->original->mp4;

//etc

You can do a dd($giphy) to see all attributes:, (*22)

{#162 ▼
  +"data": {#163 ▼
    +"type": "gif"
    +"id": "qbpRDgYI5JoKk"
    ...
    +"images": {#164 ▼
      ...
      +"original": {#179 ▼
        +"url": "https://media1.giphy.com/media/qbpRDgYI5JoKk/giphy.gif"
        +"width": "500"
        ...

By IDs

A multiget version of the get GIF by ID endpoint. On this case, $giphys is an array., (*23)

Method: Giphy::getByIDs(array $ids), (*24)

$giphys = Giphy::getByIDs(['qbpRDgYI5JoKk','FiGiRei2ICzzG']);

foreach ($giphys->data as $giphy) {
    // Get id
    $giphy->id;

    // Get image original url
    $giphy->images->original->url;

    // Get image original mp4 url
    $giphy->images->original->mp4;

    //etc
}

You can do a dd($giphys) to see all attributes:, (*25)

{#162 ▼
  +"data": array:2 [▼
    0 => {#163 ▼
      +"type": "gif"
      +"id": "qbpRDgYI5JoKk"
      +"slug": "cat-qbpRDgYI5JoKk"
      ...
    }
    1 => {#182 ▼
      +"type": "gif"
      +"id": "FiGiRei2ICzzG"
      +"slug": "funny-cat-FiGiRei2ICzzG"
      ...

Stickers

The methods of Stickers are similar to the methods Giphy, so I will omit the examples of dd(), but also you can use it to view all the attributes of objects., (*26)

Search all Sticker for a word or phrase. Punctuation will be stripped and ignored. On this case, $stickers is an array., (*27)

Method: Stickers::search($query, $limit = 25, $offset = 0, $rating = null, $lang = null), (*28)

$stickers = Stickers::search('dog');

foreach ($stickers->data as $sticker) {
    // Get id
    $sticker->id;

    // Get image original url
    $sticker->images->original->url;

    // Get image original mp4 url
    $sticker->images->original->mp4;

    //etc
}

Sticker Translate

The translate API draws on search, but uses the Stickers "special sauce" to handle translating from one vocabulary to another., (*29)

Method: Stickers::translate($query, $rating = null, $lang = null), (*30)

$sticker= Stickers::translate('cat');

// Get id
$sticker->data->id;

// Get image original url
$sticker->data->images->original->url;

// Get image original mp4 url
$sticker->data->images->original->mp4;

//etc

Fetch Stickers currently trending online. On this case, $stickers is an array., (*31)

Method: Stickers::trending($limit = 25, $rating = null), (*32)

$stickers = Stickers::trending();

foreach ($stickers->data as $sticker) {
    // Get id
    $sticker->id;

    // Get image original url
    $sticker->images->original->url;

    // Get image original mp4 url
    $sticker->images->original->mp4;

    //etc
}

Sticker Random

Returns a random Sticker, limited by tag., (*33)

Method: Stickers::random($query, $rating = null), (*34)

$sticker = Stickers::random('cat');

// Get id
$sticker->data->id;

// Get image original url
$sticker->data->image_original_url;

// Get image mp4 url
$sticker->data->image_mp4_url;

//etc

The Versions

16/03 2018

dev-master

9999999-dev https://github.com/romeroqe/giphy-and-stickers

A package that provides an interface between Laravel and Giphy API, includes Gifs and Stickers.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Emmanuel Romero

laravel api php gif giphy sticker