PHP code example of ghanem / gfycat

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

    

ghanem / gfycat example snippets


$gfycats = Gfycat::search('cat');

foreach ($gfycats->data as $gfycat) {
    // Get id
	$gfycat->id;

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

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

	//etc
}

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

$gfycat= Gfycat::translate('cat');

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

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

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

//etc

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

$gfycats = Gfycat::trending();

foreach ($gfycats->data as $gfycat) {
    // Get id
	$gfycat->id;

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

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

	//etc
}

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

$gfycat = Gfycat::random('cat');

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

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

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

//etc

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

$gfycat= Gfycat::getByID('qbpRDgYI5JoKk');

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

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

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

//etc

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

$gfycats = Gfycat::getByIDs(['qbpRDgYI5JoKk','FiGiRei2ICzzG']);

foreach ($gfycats->data as $gfycat) {
    // Get id
	$gfycat->id;

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

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

	//etc
}

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

$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= 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

$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 = 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
bash
php artisan vendor:publish --provider="Ghanem\Gfycat\GfycatServiceProvider" --tag="config"