Skip to content

Commit

Permalink
Merge pull request #10 from vicent258/clips
Browse files Browse the repository at this point in the history
Clips
  • Loading branch information
PetterKraabol committed Aug 12, 2017
2 parents 530f937 + e2fff84 commit fe14c5f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/clips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Users

Clip objects, top lists.

[Twitch API](https://github.com/justintv/Twitch-API/blob/master/clips.md)

## Functions

`$token` is an optional parameter, but required to be set somewhere.

```php
<?php

// Clip object
clip($slug);

// List of clips in a time period, ordered by views
topClips($options);


## Example Usage

File: `App/Https/Controllers/VideosController.php`

```php
<?php

namespace App\Http\Controllers;

use TwitchApi;
use App\Http\Controllers\Controller;

class ClipsController extends Controller
{
public function getClip()
{
// https://clips.twitch.tv/AgreeableOutstandingChickenStinkyCheese
$slug = "AgreeableOutstandingChickenStinkyCheese";
return TwitchApi::clip($slug);
}
}
```
36 changes: 36 additions & 0 deletions src/API/Clips.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Zarlach\TwitchApi\API;

/**
* Twitch documentation: https://github.com/justintv/Twitch-API/blob/master/v3_resources/clips.md.
*/
class Clips extends Api
{
/**
* Get clip object.
*
* @param string $slug Clip ID, example: HelloMom
*
* @return JSON Clip object
*/
public function clip($slug)
{
return $this->sendRequest('GET', 'clips/'.$slug);
}

/**
* Get top clips by number of views.
*
* @param array $options Video list options
*
* @return JSON List of videos
*/
public function clipsTop($options = [])
{
$availableOptions = ['limit', 'offset', 'game', 'period','limit','trending'];

return $this->sendRequest('GET', 'clips/top', false, $options, $availableOptions);
}

}
19 changes: 19 additions & 0 deletions src/Services/TwitchApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Zarlach\TwitchApi\API\Teams;
use Zarlach\TwitchApi\API\Users;
use Zarlach\TwitchApi\API\Videos;
use Zarlach\TwitchApi\API\Clips;

class TwitchApiService extends Api
{
Expand Down Expand Up @@ -357,4 +358,22 @@ public function channelVideos($channel, $options = [])

return $videos->channelVideos($channel, $options);
}
/**
* Clips.
*/
public function clip($slug)
{
$clips = new Clips();

return $clips->clip($slug);
}

public function topClips($options = [])
{
$clips = new Clips();

return $clips->clipsTop($options);
}


}

0 comments on commit fe14c5f

Please sign in to comment.